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.28 lib/access/autocomplete.rb
access-2.0.27 lib/access/autocomplete.rb
access-2.0.26 lib/access/autocomplete.rb
access-2.0.25 lib/access/autocomplete.rb
access-2.0.24 lib/access/autocomplete.rb
access-2.0.23 lib/access/autocomplete.rb
access-2.0.22 lib/access/autocomplete.rb
access-2.0.21 lib/access/autocomplete.rb
access-2.0.20 lib/access/autocomplete.rb
access-2.0.19 lib/access/autocomplete.rb
access-2.0.18 lib/access/autocomplete.rb
access-2.0.17 lib/access/autocomplete.rb
access-2.0.15 lib/access/autocomplete.rb
access-2.0.14 lib/access/autocomplete.rb
access-2.0.13 lib/access/autocomplete.rb
access-2.0.11 lib/access/autocomplete.rb
access-2.0.10 lib/access/autocomplete.rb
access-2.0.9 lib/access/autocomplete.rb
access-2.0.8 lib/access/autocomplete.rb
access-2.0.7 lib/access/autocomplete.rb