Class: Access::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/access/store.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values) ⇒ Store

Returns a new instance of Store.



20
21
22
23
24
25
26
27
28
# File 'lib/access/store.rb', line 20

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
  @links = Access::Link.new(@links) if @links
  @store_categories = Access::Category.process_batch(@store_categories) if @store_categories
  @physical_location = Access::Location.new(@physical_location) if @physical_location
end

Class Method Details

.find(store_key, options = {}) ⇒ Object



8
9
10
# File 'lib/access/store.rb', line 8

def self.find(store_key, options = {})
  Access::Api.new.find_store store_key, options
end

.national(options = {}) ⇒ Object



12
13
14
# File 'lib/access/store.rb', line 12

def self.national(options = {})
  Access::Api.new.national_stores options
end

.process_batch(chunk) ⇒ Object



16
17
18
# File 'lib/access/store.rb', line 16

def self.process_batch(chunk)
  chunk.map { |store| new(store) }
end

.search(options = {}) ⇒ Object



4
5
6
# File 'lib/access/store.rb', line 4

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