Module: Rails3Generators::Helpers::Model
- Defined in:
- lib/generators/helpers/model_helper.rb
Instance Attribute Summary collapse
-
#model_attributes ⇒ Object
Returns the value of attribute model_attributes.
-
#model_indexes ⇒ Object
Returns the value of attribute model_indexes.
Instance Method Summary collapse
- #arg_name(arg) ⇒ Object
- #arg_type(arg) ⇒ Object
- #class_name ⇒ Object
- #model_exists? ⇒ Boolean
- #model_name ⇒ Object
- #parse_model_attributes(with_indexes = true) ⇒ Object
- #plural_class_name ⇒ Object
- #plural_name ⇒ Object
- #singular_name ⇒ Object
Instance Attribute Details
#model_attributes ⇒ Object
Returns the value of attribute model_attributes.
5 6 7 |
# File 'lib/generators/helpers/model_helper.rb', line 5 def model_attributes @model_attributes end |
#model_indexes ⇒ Object
Returns the value of attribute model_indexes.
5 6 7 |
# File 'lib/generators/helpers/model_helper.rb', line 5 def model_indexes @model_indexes end |
Instance Method Details
#arg_name(arg) ⇒ Object
12 13 14 |
# File 'lib/generators/helpers/model_helper.rb', line 12 def arg_name(arg) arg.split(':').first end |
#arg_type(arg) ⇒ Object
16 17 18 |
# File 'lib/generators/helpers/model_helper.rb', line 16 def arg_type(arg) arg.split(':')[1] || 'string' end |
#class_name ⇒ Object
36 37 38 |
# File 'lib/generators/helpers/model_helper.rb', line 36 def class_name model_name.camelize end |
#model_exists? ⇒ Boolean
24 25 26 |
# File 'lib/generators/helpers/model_helper.rb', line 24 def model_exists? File.exist? destination_path("app/models/#{singular_name}.rb") end |
#model_name ⇒ Object
20 21 22 |
# File 'lib/generators/helpers/model_helper.rb', line 20 def model_name name end |
#parse_model_attributes(with_indexes = true) ⇒ Object
7 8 9 10 |
# File 'lib/generators/helpers/model_helper.rb', line 7 def parse_model_attributes(with_indexes = true) @model_attributes = [] @model_indexes = {} end |
#plural_class_name ⇒ Object
40 41 42 |
# File 'lib/generators/helpers/model_helper.rb', line 40 def plural_class_name plural_name.camelize end |
#plural_name ⇒ Object
32 33 34 |
# File 'lib/generators/helpers/model_helper.rb', line 32 def plural_name model_name.underscore.pluralize end |
#singular_name ⇒ Object
28 29 30 |
# File 'lib/generators/helpers/model_helper.rb', line 28 def singular_name model_name.underscore end |