Class: SerializableGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- SerializableGenerator
- Defined in:
- lib/generators/serializable/serializable_generator.rb
Instance Method Summary collapse
Instance Method Details
#create_serializer_file ⇒ Object
14 15 16 17 18 |
# File 'lib/generators/serializable/serializable_generator.rb', line 14 def create_serializer_file @serializer_name = [:name] || "#{class_name}Serializer" file_name = @serializer_name.underscore template "serializer.erb", File.join("app/serializers", class_path, "#{file_name}.rb") end |
#create_test_file ⇒ Object
20 21 22 23 |
# File 'lib/generators/serializable/serializable_generator.rb', line 20 def create_test_file @serializer_name = [:name] || "#{class_name}Serializer" (Bundler.load.specs.find { |s| s.name == "rspec-rails" }) ? create_rspec_test_file : create_minitest_test_file end |
#modify_model_file ⇒ Object
8 9 10 11 12 |
# File 'lib/generators/serializable/serializable_generator.rb', line 8 def modify_model_file inject_into_class File.join("app/models", class_path, "#{class_name.underscore}.rb"), class_name do " include Barley::Serializable\n" end end |