Class: ActiveModel::Generators::ModelGenerator
- Inherits:
-
Base
- Object
- Rails::Generators::NamedBase
- Base
- ActiveModel::Generators::ModelGenerator
- Defined in:
- lib/generators/active_model/model/model_generator.rb
Instance Method Summary collapse
- #accessor_properties ⇒ Object
- #accessor_properties? ⇒ Boolean
- #create_model_file ⇒ Object
- #read_properties ⇒ Object
- #read_properties? ⇒ Boolean
- #write_properties ⇒ Object
- #write_properties? ⇒ Boolean
Methods inherited from Base
Instance Method Details
#accessor_properties ⇒ Object
34 35 36 |
# File 'lib/generators/active_model/model/model_generator.rb', line 34 def accessor_properties attributes.select{|attr| attr.type == :all }.map{|attr| ":#{attr.name}" }.join(",") end |
#accessor_properties? ⇒ Boolean
30 31 32 |
# File 'lib/generators/active_model/model/model_generator.rb', line 30 def accessor_properties? attributes.any?{|attr| attr.type == :all } end |
#create_model_file ⇒ Object
10 11 12 |
# File 'lib/generators/active_model/model/model_generator.rb', line 10 def create_model_file template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb") end |
#read_properties ⇒ Object
18 19 20 |
# File 'lib/generators/active_model/model/model_generator.rb', line 18 def read_properties attributes.select{|attr| attr.type == :read}.map{|attr| ":#{attr.name}" }.join(",") end |
#read_properties? ⇒ Boolean
14 15 16 |
# File 'lib/generators/active_model/model/model_generator.rb', line 14 def read_properties? attributes.any?{|attr| attr.type == :read } end |
#write_properties ⇒ Object
26 27 28 |
# File 'lib/generators/active_model/model/model_generator.rb', line 26 def write_properties attributes.select{|attr| attr.type == :write }.map{|attr| ":#{attr.name}" }.join(",") end |
#write_properties? ⇒ Boolean
22 23 24 |
# File 'lib/generators/active_model/model/model_generator.rb', line 22 def write_properties? attributes.any?{|attr| attr.type == :write } end |