Sha256: c5718fc8542b4154b1d22cf6661a74f70fa570c8f723e0d700b067343b51a9cf

Contents?: true

Size: 880 Bytes

Versions: 19

Compression:

Stored size: 880 Bytes

Contents

module Access
  class Offer
    attr_reader :store, :location

    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.process_batch(chunk)
      chunk.map { |offer| new(offer) }
    end

    def initialize(values)
      self.class.class_eval { attr_reader *values.keys }
      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
    end

    def location
      @offer_store.physical_location
    end

    def store
      @offer_store
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
access-2.0.21 lib/access/offer.rb
access-2.0.20 lib/access/offer.rb
access-2.0.19 lib/access/offer.rb
access-2.0.18 lib/access/offer.rb
access-2.0.17 lib/access/offer.rb
access-2.0.15 lib/access/offer.rb
access-2.0.14 lib/access/offer.rb
access-2.0.13 lib/access/offer.rb
access-2.0.11 lib/access/offer.rb
access-2.0.10 lib/access/offer.rb
access-2.0.9 lib/access/offer.rb
access-2.0.8 lib/access/offer.rb
access-2.0.7 lib/access/offer.rb
access-2.0.5 lib/access/offer.rb
access-2.0.4 lib/access/offer.rb
access-2.0.3 lib/access/offer.rb
access-2.0.2 lib/access/offer.rb
access-2.0.1 lib/access/offer.rb
access-2.0.0 lib/access/offer.rb