Class: SixSaferpay::Generators::Model
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- SixSaferpay::Generators::Model
- Includes:
- Thor::Actions
- Defined in:
- lib/generators/models.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
Class Method Summary collapse
Instance Method Summary collapse
- #create_attributes_array ⇒ Object
- #create_fabric_file ⇒ Object
- #create_model_file ⇒ Object
- #create_test_file ⇒ Object
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
9 10 11 |
# File 'lib/generators/models.rb', line 9 def attributes @attributes end |
#file_name ⇒ Object
Returns the value of attribute file_name.
9 10 11 |
# File 'lib/generators/models.rb', line 9 def file_name @file_name end |
Class Method Details
.source_root ⇒ Object
15 16 17 |
# File 'lib/generators/models.rb', line 15 def self.source_root File.dirname(__FILE__) end |
Instance Method Details
#create_attributes_array ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/generators/models.rb', line 23 def create_attributes_array @attributes = [] if method_attributes method_attributes.each do |key, value| split = value.split(':') name = key.underscore type = split.first if split.length == 2 mandatory = split.last else mandatory = false end attribute = Attribute.new(name, type, mandatory) @attributes << attribute end end end |
#create_fabric_file ⇒ Object
52 53 54 |
# File 'lib/generators/models.rb', line 52 def create_fabric_file template('templates/fabric.erb', "spec/fabrics/six_saferpay/models/#{@file_name.pluralize}.rb") end |
#create_model_file ⇒ Object
44 45 46 |
# File 'lib/generators/models.rb', line 44 def create_model_file template('templates/model.erb', "lib/six_saferpay/models/#{@file_name}.rb") end |
#create_test_file ⇒ Object
48 49 50 |
# File 'lib/generators/models.rb', line 48 def create_test_file template('templates/spec.erb', "spec/six_saferpay/models/#{@file_name}_spec.rb") end |