Advertisement
Guest User

Untitled

a guest
Mar 10th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.56 KB | None | 0 0
  1.   def custom_value(promotion=nil)
  2.     return nil if promotion.nil?
  3.     if @promotion_custom_point_values.nil? or @current_promotion != promotion
  4.       Rails.cache.fetch("custom_value_#{promotion.id}", :expires_in => 5.minutes, :race_condition_ttl => 10) do
  5.         @promotion_custom_point_values = promotion.custom_point_values.reduce({}) do |hash, value|
  6.           hash[value.action_id] = value if !hash.has_key?(value.action_id)
  7.           hash
  8.         end
  9.       end
  10.     end
  11.     @current_promotion = promotion
  12.     @promotion_custom_point_values[self.id]
  13.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement