lib/access/store.rb in access-1.1.7 vs lib/access/store.rb in access-2.0.0
- old
+ new
@@ -3,15 +3,29 @@
def self.search(options = {})
Access::Api.new.search_stores options
end
- def self.find(key, options = {})
- Access::Api.new.find_store key, options
+ def self.find(store_key, options = {})
+ Access::Api.new.find_store store_key, options
end
def self.national(options = {})
Access::Api.new.national_stores options
+ end
+
+ def self.process_batch(chunk)
+ chunk.map { |store| new(store) }
+ 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
+ @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
end
end