Sha256: 4dcb6625eec217b3d83c1ff42a392a214773d6b13ec7706a1aee81062b6250e3

Contents?: true

Size: 1.11 KB

Versions: 46

Compression:

Stored size: 1.11 KB

Contents

module Access
  class Autocomplete

    def self.search(options = {})
      Access::Api.new.autocomplete options
    end

    def self.search_stores(options = {})
      Access::Api.new.autocomplete options.merge(resources: 'stores')
    end

    def self.search_categories(options = {})
      Access::Api.new.autocomplete options.merge(resources: 'categories')
    end

    def self.search_offers(options = {})
      Access::Api.new.autocomplete options.merge(resources: 'offers')
    end

    def self.search_locations(options = {})
      Access::Api.new.autocomplete options.merge(resources: 'locations')
    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
      @offers = Access::Offer.process_batch(@offers) if @offers
      @stores = Access::Store.process_batch(@stores) if @stores
      @locations = Access::Location.process_batch(@locations) if @locations
      @categories = Access::Category.process_batch(@categories) if @categories
    end

  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
access-2.0.5 lib/access/autocomplete.rb
access-2.0.4 lib/access/autocomplete.rb
access-2.0.3 lib/access/autocomplete.rb
access-2.0.2 lib/access/autocomplete.rb
access-2.0.1 lib/access/autocomplete.rb
access-2.0.0 lib/access/autocomplete.rb