Class: BBMB::Model::Order::Position
- Inherits:
-
Object
- Object
- BBMB::Model::Order::Position
show all
- Includes:
- Util::Numbers, ODBA::Persistable
- Defined in:
- lib/bbmb/model/order.rb,
lib/bbmb/persistence/odba/model/order.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
append_features
Constructor Details
#initialize(quantity, product) ⇒ Position
Returns a new instance of Position.
21
22
23
24
|
# File 'lib/bbmb/model/order.rb', line 21
def initialize(quantity, product)
@quantity = quantity
@product = product
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
33
34
35
|
# File 'lib/bbmb/model/order.rb', line 33
def method_missing(name, *args, &block)
@product.send(name, *args, &block) if @product
end
|
Instance Attribute Details
#product ⇒ Object
Returns the value of attribute product.
18
19
20
|
# File 'lib/bbmb/model/order.rb', line 18
def product
@product
end
|
Instance Method Details
#__old_commit__ ⇒ Object
11
12
13
|
# File 'lib/bbmb/persistence/odba/model/order.rb', line 11
def commit!
@product = @product.to_info
end
|
#commit!(*args) ⇒ Object
25
26
27
|
# File 'lib/bbmb/model/order.rb', line 25
def commit!
@product = @product.to_info
end
|
#freebies ⇒ Object
28
29
30
31
32
|
# File 'lib/bbmb/model/order.rb', line 28
def freebies
if(promo = @product.current_promo)
promo.freebies(@quantity)
end
end
|
#price ⇒ Object
36
37
38
|
# File 'lib/bbmb/model/order.rb', line 36
def price
@price_effective || price_effective
end
|
#price_effective(qty = @quantity) ⇒ Object
39
40
41
|
# File 'lib/bbmb/model/order.rb', line 39
def price_effective(qty = @quantity)
@product.price_effective(qty)
end
|
#price_qty(qty = @quantity) ⇒ Object
42
43
44
|
# File 'lib/bbmb/model/order.rb', line 42
def price_qty(qty = @quantity)
@product.price_qty(qty) if @product
end
|
#respond_to?(name) ⇒ Boolean
48
49
50
|
# File 'lib/bbmb/model/order.rb', line 48
def respond_to?(name)
super(name) || @product.respond_to?(name)
end
|
#total ⇒ Object
45
46
47
|
# File 'lib/bbmb/model/order.rb', line 45
def total
price * @quantity
end
|