module ApiScaffold::Generators::GeneratorHelpers
Public Instance Methods
attributes_hash()
click to toggle source
# File lib/generators/api_scaffold/generator_helpers.rb, line 49 def attributes_hash return {} if attributes_names.empty? attributes_names.map do |name| if %w(password password_confirmation).include?(name) && attributes.any?(&:password_digest?) ["#{name}", "'secret'"] else ["#{name}", "@#{singular_table_name}.#{name}"] end end.sort.to_h end
attributes_string()
click to toggle source
# File lib/generators/api_scaffold/generator_helpers.rb, line 45 def attributes_string attributes_hash.map { |k, v| "#{k}: #{v}" }.join(", ") end
error_serializer_created?()
click to toggle source
# File lib/generators/api_scaffold/generator_helpers.rb, line 25 def error_serializer_created? File.exists? File.join(destination_root, "app/serializers/error_serializer.rb") end
fixture_name()
click to toggle source
# File lib/generators/api_scaffold/generator_helpers.rb, line 37 def fixture_name if mountable_engine? (namespace_dirs + [table_name]).join("_") else table_name end end
fixture_replacement()
click to toggle source
# File lib/generators/api_scaffold/generator_helpers.rb, line 33 def fixture_replacement Rails.application.config.generators.options[:rails][:fixture_replacement] end
gem_available?(gem_name)
click to toggle source
# File lib/generators/api_scaffold/generator_helpers.rb, line 21 def gem_available?(gem_name) Gem::Specification::find_all_by_name(gem_name).any? end
prefix()
click to toggle source
# File lib/generators/api_scaffold/generator_helpers.rb, line 5 def prefix "v#{options[:api_version]}" end
prefixed_class_name()
click to toggle source
# File lib/generators/api_scaffold/generator_helpers.rb, line 9 def prefixed_class_name "Api::#{prefix.capitalize}::#{class_name}" end
prefixed_controller_class_name()
click to toggle source
# File lib/generators/api_scaffold/generator_helpers.rb, line 13 def prefixed_controller_class_name "Api::#{prefix.capitalize}::#{controller_class_name}" end
prefixed_url(resource)
click to toggle source
# File lib/generators/api_scaffold/generator_helpers.rb, line 17 def prefixed_url(resource) ['api', prefix, resource, 'url'].join('_') end
test_framework()
click to toggle source
# File lib/generators/api_scaffold/generator_helpers.rb, line 29 def test_framework Rails.application.config.generators.options[:rails][:test_framework] end