Class: SerializerGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/serializer/serializer_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_serializer_fileObject



8
9
10
11
12
# File 'lib/generators/serializer/serializer_generator.rb', line 8

def create_serializer_file
  @serializer_name = options[:name] || "#{class_name}Serializer"
  file_name = @serializer_name.underscore
  template "serializer.erb", File.join("app/serializers", class_path, "#{file_name}.rb")
end

#create_test_fileObject



14
15
16
17
# File 'lib/generators/serializer/serializer_generator.rb', line 14

def create_test_file
  @serializer_name = options[:name] || "#{class_name}Serializer"
  (Bundler.load.specs.find { |s| s.name == "rspec-rails" }) ? create_rspec_test_file : create_minitest_test_file
end