Class: Xpost::Models::Item
- Inherits:
-
Object
- Object
- Xpost::Models::Item
- Includes:
- ActiveModel::Model
- Defined in:
- lib/xpost/models/item.rb
Constant Summary collapse
- ITEM_TYPES =
Set[:product, :shipping, :tax, :fee, :insurance, :discount]
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#description ⇒ Object
Returns the value of attribute description.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #check_item_type ⇒ Object
-
#initialize(options = {}) ⇒ Item
constructor
A new instance of Item.
Constructor Details
#initialize(options = {}) ⇒ Item
Returns a new instance of Item.
16 17 18 19 20 21 22 |
# File 'lib/xpost/models/item.rb', line 16 def initialize( = {}) @type = [:type] @description = [:description] @amount = [:amount] @quantity = [:quantity] @metadata = [:metadata] end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
11 12 13 |
# File 'lib/xpost/models/item.rb', line 11 def amount @amount end |
#description ⇒ Object
Returns the value of attribute description.
11 12 13 |
# File 'lib/xpost/models/item.rb', line 11 def description @description end |
#metadata ⇒ Object
Returns the value of attribute metadata.
11 12 13 |
# File 'lib/xpost/models/item.rb', line 11 def @metadata end |
#quantity ⇒ Object
Returns the value of attribute quantity.
11 12 13 |
# File 'lib/xpost/models/item.rb', line 11 def quantity @quantity end |
#type ⇒ Object
Returns the value of attribute type.
11 12 13 |
# File 'lib/xpost/models/item.rb', line 11 def type @type end |
Instance Method Details
#check_item_type ⇒ Object
24 25 26 27 28 |
# File 'lib/xpost/models/item.rb', line 24 def check_item_type if self.type.present? && !ITEM_TYPES.include?(self.type.to_sym) errors.add(:type, "wrong item type") end end |