Class: CartGenerator
- Inherits:
-
ActiveRecord::Generators::Base
- Object
- ActiveRecord::Generators::Base
- CartGenerator
- Defined in:
- lib/generators/cart_generator.rb
Instance Attribute Summary collapse
-
#product_cname ⇒ Object
Returns the value of attribute product_cname.
-
#user_cname ⇒ Object
Returns the value of attribute user_cname.
Instance Method Summary collapse
- #copy_cart_migration ⇒ Object
- #ensure_defined ⇒ Object
- #generate_model ⇒ Object
-
#initialize(*args) ⇒ CartGenerator
constructor
A new instance of CartGenerator.
Constructor Details
#initialize(*args) ⇒ CartGenerator
Returns a new instance of CartGenerator.
7 8 9 10 11 |
# File 'lib/generators/cart_generator.rb', line 7 def initialize *args @user_cname = args[0][0] @product_cname = args[0][1] super end |
Instance Attribute Details
#product_cname ⇒ Object
Returns the value of attribute product_cname.
4 5 6 |
# File 'lib/generators/cart_generator.rb', line 4 def product_cname @product_cname end |
#user_cname ⇒ Object
Returns the value of attribute user_cname.
4 5 6 |
# File 'lib/generators/cart_generator.rb', line 4 def user_cname @user_cname end |
Instance Method Details
#copy_cart_migration ⇒ Object
23 24 25 |
# File 'lib/generators/cart_generator.rb', line 23 def copy_cart_migration migration_template "migration.rb", "db/migrate/create_carts.rb" end |
#ensure_defined ⇒ Object
13 14 15 |
# File 'lib/generators/cart_generator.rb', line 13 def ensure_defined ensure_classes_defined [:user, :product] end |
#generate_model ⇒ Object
17 18 19 20 21 |
# File 'lib/generators/cart_generator.rb', line 17 def generate_model invoke "active_record:model", [ "cart" ], :migration => false inject_into_class model_path, Cart, model_content end |