Class: Jazz::Generators::Model
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Jazz::Generators::Model
- Includes:
- Thor::Actions
- Defined in:
- lib/jazz/generators/model/model.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #convert_attributes ⇒ Object
- #create ⇒ Object
- #create_database ⇒ Object
- #create_fixture ⇒ Object
- #create_model ⇒ Object
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/jazz/generators/model/model.rb', line 6 def attributes @attributes end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/jazz/generators/model/model.rb', line 6 def name @name end |
Class Method Details
.source_root ⇒ Object
8 9 10 |
# File 'lib/jazz/generators/model/model.rb', line 8 def self.source_root File.join(File.dirname(__FILE__)) end |
Instance Method Details
#convert_attributes ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jazz/generators/model/model.rb', line 31 def convert_attributes @attribute_hash = Hash.new attributes.each do |attribute| val = attribute.split(':') if val[0] && val[1] @attribute_hash[val[0]] = val[1] end end self.attributes = {} self.attributes = @attribute_hash end |
#create ⇒ Object
12 13 14 15 16 17 |
# File 'lib/jazz/generators/model/model.rb', line 12 def create convert_attributes create_model create_database create_fixture end |
#create_database ⇒ Object
23 24 25 |
# File 'lib/jazz/generators/model/model.rb', line 23 def create_database template "templates/database.js", "db/create/create_#{name.pluralize.downcase}.js" end |
#create_fixture ⇒ Object
27 28 29 |
# File 'lib/jazz/generators/model/model.rb', line 27 def create_fixture template "templates/fixture.js", "db/fixtures/#{name.pluralize.downcase}.js" end |
#create_model ⇒ Object
19 20 21 |
# File 'lib/jazz/generators/model/model.rb', line 19 def create_model template "templates/model.js", "app/models/#{name.singularize.downcase}.js" end |