Sha256: d76f652c85fe438747709137ca225c2df1ac8f7bd2fdcd29bf6a8128c45502b1
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
module Access class Offer attr_reader :store, :location, :used_fields def self.search(options = {}) Access::Api.new.search_offers options end def self.find(offer_key, options = {}) Access::Api.new.find_offer offer_key, options end def self.find_uses_remaining(offer_key, options = {}) Access::Api.new.find_offer_uses_remaining offer_key, options end def self.process_batch(chunk) chunk.map { |offer| new(offer) } end def initialize(values) unless Access.config.used_fields == 'true' self.class.class_eval { attr_reader *values.keys } else self.class.class_eval do values.keys.each do |k| define_method(k.to_sym) do @used_fields ||= [] @used_fields << k.to_sym instance_variable_get("@#{k.to_sym}") end end end end values.each do |attribute_name, attribute_value| self.instance_variable_set("@#{attribute_name}", attribute_value) end @categories = Access::Category.process_batch(@categories) if @categories @links = Access::Link.new(@links) if @links @offer_store = Access::Store.new(@offer_store) if @offer_store @offer_uses_remaining = Access::Redemption.new(@offer_uses_remaining) if @offer_uses_remaining end def location @offer_store.physical_location end def store @offer_store end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
access-2.0.50 | lib/access/offer.rb |