Class: Spree::PromotionHandler::Page

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/promotion_handler/page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order, path) ⇒ Page

Returns a new instance of Page.



8
9
10
11
# File 'app/models/spree/promotion_handler/page.rb', line 8

def initialize(order, path)
  @order = order
  @path = path.delete_prefix('/')
end

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



6
7
8
# File 'app/models/spree/promotion_handler/page.rb', line 6

def order
  @order
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'app/models/spree/promotion_handler/page.rb', line 6

def path
  @path
end

Instance Method Details

#activateObject



13
14
15
16
17
# File 'app/models/spree/promotion_handler/page.rb', line 13

def activate
  if promotion && promotion.eligible?(order)
    promotion.activate(order:)
  end
end