Module: EffectiveProductsRingWizard
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/effective_products_ring_wizard.rb
Overview
EffectiveProductsRingWizard
Mark your owner model with effective_products_ring_wizard to get all the includes
Defined Under Namespace
Modules: Base, ClassMethods
Instance Method Summary collapse
- #assign_pricing ⇒ Object
- #build_ring ⇒ Object
- #done? ⇒ Boolean
- #in_progress? ⇒ Boolean
- #ring ⇒ Object
-
#ring! ⇒ Object
After the configure Ring step.
-
#to_s ⇒ Object
Instance Methods.
Instance Method Details
#assign_pricing ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'app/models/concerns/effective_products_ring_wizard.rb', line 118 def assign_pricing raise('assign_pricing() to be implemented by including class') # raise('expected a persisted ring') unless ring&.persisted? # price = case ring.metal # when '14k Yellow Gold' then 450_00 # when 'Sterling Silver' then 175_00 # when 'Titanium' then 50_00 # else # raise "unexpected ring metal: #{ring.metal || 'none'}" # end # qb_item_name = "Professional Ring" # tax_exempt = false # ring.assign_attributes(price: price, qb_item_name: qb_item_name, tax_exempt: tax_exempt) end |
#build_ring ⇒ Object
108 109 110 111 112 113 114 115 116 |
# File 'app/models/concerns/effective_products_ring_wizard.rb', line 108 def build_ring ring = rings.build(owner: owner) if (address = owner.try(:shipping_address) || owner.try(:billing_address)).present? ring.shipping_address = address end ring end |
#done? ⇒ Boolean
100 101 102 |
# File 'app/models/concerns/effective_products_ring_wizard.rb', line 100 def done? submitted? end |
#in_progress? ⇒ Boolean
96 97 98 |
# File 'app/models/concerns/effective_products_ring_wizard.rb', line 96 def in_progress? draft? end |
#ring ⇒ Object
104 105 106 |
# File 'app/models/concerns/effective_products_ring_wizard.rb', line 104 def ring rings.first end |
#ring! ⇒ Object
After the configure Ring step
138 139 140 141 142 143 |
# File 'app/models/concerns/effective_products_ring_wizard.rb', line 138 def ring! assign_pricing() if ring.present? raise('expected ring to have a price') if ring.price.blank? save! end |
#to_s ⇒ Object
Instance Methods
92 93 94 |
# File 'app/models/concerns/effective_products_ring_wizard.rb', line 92 def to_s 'ring payment' end |