Class: Akatus::Order
- Inherits:
-
Object
- Object
- Akatus::Order
- Defined in:
- lib/akatus/order.rb
Instance Attribute Summary collapse
-
#address(attributes = {}) ⇒ Object
Returns the value of attribute address.
-
#buyer_email ⇒ Object
Returns the value of attribute buyer_email.
-
#buyer_name ⇒ Object
Returns the value of attribute buyer_name.
-
#credit_card(attributes = {}) ⇒ Object
Returns the value of attribute credit_card.
-
#discount_amount ⇒ Object
Returns the value of attribute discount_amount.
-
#freight_amount ⇒ Object
Returns the value of attribute freight_amount.
-
#installments ⇒ Object
Returns the value of attribute installments.
-
#payment_method ⇒ Object
Returns the value of attribute payment_method.
-
#phone(attributes = {}) ⇒ Object
Returns the value of attribute phone.
-
#products ⇒ Object
Returns the value of attribute products.
-
#reference ⇒ Object
Returns the value of attribute reference.
-
#weight ⇒ Object
Returns the value of attribute weight.
Instance Method Summary collapse
- #add_product(attributes = {}) ⇒ Object
- #credit_card? ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Order
constructor
A new instance of Order.
Constructor Details
#initialize(attributes = {}) ⇒ Order
Returns a new instance of Order.
7 8 9 10 11 12 |
# File 'lib/akatus/order.rb', line 7 def initialize(attributes = {}) attributes.each do |name, value| send("#{name}=", value) end self.products = [] end |
Instance Attribute Details
#address(attributes = {}) ⇒ Object
Returns the value of attribute address.
3 4 5 |
# File 'lib/akatus/order.rb', line 3 def address @address end |
#buyer_email ⇒ Object
Returns the value of attribute buyer_email.
3 4 5 |
# File 'lib/akatus/order.rb', line 3 def buyer_email @buyer_email end |
#buyer_name ⇒ Object
Returns the value of attribute buyer_name.
3 4 5 |
# File 'lib/akatus/order.rb', line 3 def buyer_name @buyer_name end |
#credit_card(attributes = {}) ⇒ Object
Returns the value of attribute credit_card.
3 4 5 |
# File 'lib/akatus/order.rb', line 3 def credit_card @credit_card end |
#discount_amount ⇒ Object
Returns the value of attribute discount_amount.
3 4 5 |
# File 'lib/akatus/order.rb', line 3 def discount_amount @discount_amount end |
#freight_amount ⇒ Object
Returns the value of attribute freight_amount.
3 4 5 |
# File 'lib/akatus/order.rb', line 3 def freight_amount @freight_amount end |
#installments ⇒ Object
Returns the value of attribute installments.
3 4 5 |
# File 'lib/akatus/order.rb', line 3 def installments @installments end |
#payment_method ⇒ Object
Returns the value of attribute payment_method.
3 4 5 |
# File 'lib/akatus/order.rb', line 3 def payment_method @payment_method end |
#phone(attributes = {}) ⇒ Object
Returns the value of attribute phone.
3 4 5 |
# File 'lib/akatus/order.rb', line 3 def phone @phone end |
#products ⇒ Object
Returns the value of attribute products.
3 4 5 |
# File 'lib/akatus/order.rb', line 3 def products @products end |
#reference ⇒ Object
Returns the value of attribute reference.
3 4 5 |
# File 'lib/akatus/order.rb', line 3 def reference @reference end |
#weight ⇒ Object
Returns the value of attribute weight.
3 4 5 |
# File 'lib/akatus/order.rb', line 3 def weight @weight end |
Instance Method Details
#add_product(attributes = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/akatus/order.rb', line 14 def add_product(attributes = {}) self.products << Product.new({ :code => attributes[:code], :name => attributes[:name], :weight => attributes[:weight], :quantity => attributes[:quantity], :freight_amount => attributes[:freight_amount], :discount_amount => attributes[:discount_amount], :price => attributes[:price] }) end |
#credit_card? ⇒ Boolean
59 60 61 |
# File 'lib/akatus/order.rb', line 59 def credit_card? %w{cartao_visa cartao_master cartao_amex cartao_diners cartao_elo cartao_hipercard}.include? payment_method end |