Class: Transporter
- Inherits:
-
Ruleby::Rulebook
- Object
- Ruleby::Rulebook
- Transporter
- Defined in:
- lib/transporter.rb
Instance Attribute Summary collapse
-
#cart ⇒ Object
writeonly
Sets the attribute cart.
-
#order ⇒ Object
writeonly
Sets the attribute order.
-
#transporter_ids ⇒ Object
writeonly
Sets the attribute transporter_ids.
Instance Method Summary collapse
Instance Attribute Details
#cart=(value) ⇒ Object (writeonly)
Sets the attribute cart
4 5 6 |
# File 'lib/transporter.rb', line 4 def cart=(value) @cart = value end |
#order=(value) ⇒ Object (writeonly)
Sets the attribute order
4 5 6 |
# File 'lib/transporter.rb', line 4 def order=(value) @order = value end |
#transporter_ids=(value) ⇒ Object (writeonly)
Sets the attribute transporter_ids
4 5 6 |
# File 'lib/transporter.rb', line 4 def transporter_ids=(value) @transporter_ids = value end |
Instance Method Details
#rules ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/transporter.rb', line 6 def rules TransporterRule.find_all_by_active(true).each do |transporter| condition = transporter.conditions condition.gsub!(/Cart/,'Order') unless @cart rule eval(condition) do |context| if @cart && @cart.address_delivery && !transporter.geo_zones.empty? && transporter.geo_zones.map(&:id).include?(@cart.address_delivery.country.id) @transporter_ids << transporter.id elsif @cart && @cart.address_delivery && transporter.geo_zones.empty? p 'skipped' elsif @cart && @cart.address_delivery && !transporter.geo_zones.empty? && !transporter.geo_zones.map(&:id).include?(@cart.address_delivery.country.id) p 'skipped' else @transporter_ids << transporter.id end end end @transporter_ids end |