Class: Portage::Ucp::AppliedDiscount
- Inherits:
-
Data
- Object
- Data
- Portage::Ucp::AppliedDiscount
- Defined in:
- lib/portage/ucp/value_objects.rb
Overview
schemas/shopping/discount.json#/$defs/applied_discount — requires title/
amount. code is omitted for automatic discounts; allocations (the
per-target breakdown) is left empty rather than guessed at by adapters
that can't source it from their platform.
allocation_method maps to the wire key "method" — bare :method as a
Data.define member would shadow Kernel#method.
Instance Attribute Summary collapse
-
#allocation_method ⇒ Object
readonly
Returns the value of attribute allocation_method.
-
#allocations ⇒ Object
readonly
Returns the value of attribute allocations.
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#automatic ⇒ Object
readonly
Returns the value of attribute automatic.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#eligibility ⇒ Object
readonly
Returns the value of attribute eligibility.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#provisional ⇒ Object
readonly
Returns the value of attribute provisional.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(title:, amount:, code: nil, automatic: false, allocation_method: nil, priority: nil, provisional: false, eligibility: nil, allocations: []) ⇒ AppliedDiscount
constructor
A new instance of AppliedDiscount.
- #to_wire_h ⇒ Object
Constructor Details
#initialize(title:, amount:, code: nil, automatic: false, allocation_method: nil, priority: nil, provisional: false, eligibility: nil, allocations: []) ⇒ AppliedDiscount
Returns a new instance of AppliedDiscount.
220 221 222 223 |
# File 'lib/portage/ucp/value_objects.rb', line 220 def initialize(title:, amount:, code: nil, automatic: false, allocation_method: nil, priority: nil, provisional: false, eligibility: nil, allocations: []) super end |
Instance Attribute Details
#allocation_method ⇒ Object (readonly)
Returns the value of attribute allocation_method
218 219 220 |
# File 'lib/portage/ucp/value_objects.rb', line 218 def allocation_method @allocation_method end |
#allocations ⇒ Object (readonly)
Returns the value of attribute allocations
218 219 220 |
# File 'lib/portage/ucp/value_objects.rb', line 218 def allocations @allocations end |
#amount ⇒ Object (readonly)
Returns the value of attribute amount
218 219 220 |
# File 'lib/portage/ucp/value_objects.rb', line 218 def amount @amount end |
#automatic ⇒ Object (readonly)
Returns the value of attribute automatic
218 219 220 |
# File 'lib/portage/ucp/value_objects.rb', line 218 def automatic @automatic end |
#code ⇒ Object (readonly)
Returns the value of attribute code
218 219 220 |
# File 'lib/portage/ucp/value_objects.rb', line 218 def code @code end |
#eligibility ⇒ Object (readonly)
Returns the value of attribute eligibility
218 219 220 |
# File 'lib/portage/ucp/value_objects.rb', line 218 def eligibility @eligibility end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority
218 219 220 |
# File 'lib/portage/ucp/value_objects.rb', line 218 def priority @priority end |
#provisional ⇒ Object (readonly)
Returns the value of attribute provisional
218 219 220 |
# File 'lib/portage/ucp/value_objects.rb', line 218 def provisional @provisional end |
#title ⇒ Object (readonly)
Returns the value of attribute title
218 219 220 |
# File 'lib/portage/ucp/value_objects.rb', line 218 def title @title end |
Instance Method Details
#to_wire_h ⇒ Object
225 226 227 228 229 230 231 232 233 |
# File 'lib/portage/ucp/value_objects.rb', line 225 def to_wire_h h = { "title" => title, "amount" => amount } { code: "code", automatic: "automatic", allocation_method: "method", priority: "priority", provisional: "provisional", eligibility: "eligibility" }.each do |attr, key| h[key] = public_send(attr) if public_send(attr) end h["allocations"] = allocations if allocations.any? h end |