Class: Opensteam::Container::Item
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Opensteam::Container::Item
- Defined in:
- lib/opensteam/container.rb
Overview
Items for Container Class used for CartItems, OrderItems, etc
implements quantity mechanism (increment, decrement, set_quantity). if quantity == 0, item destroys itself. implements a method_missing to delegate all unknown method calls to (polymorphic) item.
Class Method Summary collapse
Instance Method Summary collapse
-
#decr ⇒ Object
decrement quantity.
-
#incr ⇒ Object
increment quantity.
-
#method_missing(name, *args, &block) ⇒ Object
delegate all missing methods to item, if item responds.
-
#set_quantity(qnt) ⇒ Object
set quantity and save item.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
delegate all missing methods to item, if item responds
157 158 159 |
# File 'lib/opensteam/container.rb', line 157 def method_missing(name, *args, &block ) self.item.respond_to?( name ) ? self.item.__send__( name, *args, &block ) : super end |
Class Method Details
.table_name ⇒ Object
124 |
# File 'lib/opensteam/container.rb', line 124 def self.table_name ; "container_items" ; end |
Instance Method Details
#decr ⇒ Object
decrement quantity
147 |
# File 'lib/opensteam/container.rb', line 147 def decr ; self.decrement!( :quantity, 1 ) ; end |
#incr ⇒ Object
increment quantity
144 |
# File 'lib/opensteam/container.rb', line 144 def incr ; self.increment!( :quantity, 1 ) ; end |
#set_quantity(qnt) ⇒ Object
set quantity and save item
151 152 153 154 |
# File 'lib/opensteam/container.rb', line 151 def set_quantity( qnt ) self.quantity = qnt save end |