Skip to content

Commit

Permalink
Remove Promomtion#order_activatable in favour of the class method of …
Browse files Browse the repository at this point in the history
…the same name
  • Loading branch information
radar committed Oct 21, 2013
1 parent f0525e2 commit b73c84e
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions core/app/models/spree/promotion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ def self.active
where('expires_at IS NULL OR expires_at > ?', Time.now)
end

def self.order_activatable?(order)
order && !UNACTIVATABLE_ORDER_STATES.include?(order.state)
end

def expired?
starts_at && Time.now < starts_at || expires_at && Time.now > expires_at
end

def activate(payload)
return unless order_activatable? payload[:order]
return unless self.class.order_activatable?(payload[:order])

# Track results from actions to see if any action has been taken.
# Actions should return nil/false if no action has been taken.
Expand Down Expand Up @@ -67,14 +71,6 @@ def rules_are_eligible?(promotable, options = {})
end
end

def self.order_activatable?(order)
order && !UNACTIVATABLE_ORDER_STATES.include?(order.state)
end
def order_activatable?(order)
self.class.order_activatable?(order)
end


# Products assigned to all product rules
def products
@products ||= self.rules.to_a.inject([]) do |products, rule|
Expand Down

0 comments on commit b73c84e

Please sign in to comment.