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.50 lib/access/autocomplete.rb
access-2.0.49 lib/access/autocomplete.rb
access-2.0.48 lib/access/autocomplete.rb
access-2.0.47 lib/access/autocomplete.rb
access-2.0.46 lib/access/autocomplete.rb
access-2.0.44 lib/access/autocomplete.rb
access-2.0.43 lib/access/autocomplete.rb
access-2.0.42 lib/access/autocomplete.rb
access-2.0.41 lib/access/autocomplete.rb
access-2.0.40 lib/access/autocomplete.rb
access-2.0.39 lib/access/autocomplete.rb
access-2.0.38 lib/access/autocomplete.rb
access-2.0.37 lib/access/autocomplete.rb
access-2.0.36 lib/access/autocomplete.rb
access-2.0.34 lib/access/autocomplete.rb
access-2.0.33 lib/access/autocomplete.rb
access-2.0.32 lib/access/autocomplete.rb
access-2.0.31 lib/access/autocomplete.rb
access-2.0.30 lib/access/autocomplete.rb
access-2.0.29 lib/access/autocomplete.rb