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.



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

def initialize(order, path)
  @order = order
  @store = order.store
  @path = path.gsub(/\A\//, '')
end

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



4
5
6
# File 'app/models/spree/promotion_handler/page.rb', line 4

def order
  @order
end

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'app/models/spree/promotion_handler/page.rb', line 4

def path
  @path
end

#storeObject (readonly)

Returns the value of attribute store.



4
5
6
# File 'app/models/spree/promotion_handler/page.rb', line 4

def store
  @store
end

Instance Method Details

#activateObject



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

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