Class: Access::Favorite
- Inherits:
-
Object
- Object
- Access::Favorite
- Defined in:
- lib/access/favorite.rb
Class Method Summary collapse
- .create(offer_key, options = {}) ⇒ Object
- .create_location(location_key, options = {}) ⇒ Object
- .create_offer(offer_key, options = {}) ⇒ Object
- .create_store(store_key, options = {}) ⇒ Object
- .delete(offer_key, options = {}) ⇒ Object
- .delete_location(location_key, options = {}) ⇒ Object
- .delete_offer(offer_key, options = {}) ⇒ Object
- .delete_store(store_key, options = {}) ⇒ Object
- .find(offer_key, options = {}) ⇒ Object
- .find_location(location_key, options = {}) ⇒ Object
- .find_offer(offer_key, options = {}) ⇒ Object
- .find_store(store_key, options = {}) ⇒ Object
- .process_batch(chunk) ⇒ Object
- .search(options = {}) ⇒ Object
- .search_locations(options = {}) ⇒ Object
- .search_offers(options = {}) ⇒ Object
- .search_stores(options = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(values) ⇒ Favorite
constructor
A new instance of Favorite.
- #resource ⇒ Object
Constructor Details
#initialize(values) ⇒ Favorite
Returns a new instance of Favorite.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/access/favorite.rb', line 8 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 @offer = Access::Offer.new(@offer) if @offer @location = Access::Location.new(@location) if @location @store = Access::Store.new(@store) if @store end |
Class Method Details
.create(offer_key, options = {}) ⇒ Object
55 56 57 |
# File 'lib/access/favorite.rb', line 55 def self.create(offer_key, = {}) Access::Api.new.favorites_create offer_key, end |
.create_location(location_key, options = {}) ⇒ Object
63 64 65 |
# File 'lib/access/favorite.rb', line 63 def self.create_location(location_key, = {}) Access::Api.new.favorites_create location_key, .merge(favorite_type: 'locations') end |
.create_offer(offer_key, options = {}) ⇒ Object
59 60 61 |
# File 'lib/access/favorite.rb', line 59 def self.create_offer(offer_key, = {}) Access::Api.new.favorites_create offer_key, .merge(favorite_type: 'offers') end |
.create_store(store_key, options = {}) ⇒ Object
67 68 69 |
# File 'lib/access/favorite.rb', line 67 def self.create_store(store_key, = {}) Access::Api.new.favorites_create store_key, .merge(favorite_type: 'stores') end |
.delete(offer_key, options = {}) ⇒ Object
71 72 73 |
# File 'lib/access/favorite.rb', line 71 def self.delete(offer_key, = {}) Access::Api.new.favorites_delete offer_key, end |
.delete_location(location_key, options = {}) ⇒ Object
79 80 81 |
# File 'lib/access/favorite.rb', line 79 def self.delete_location(location_key, = {}) Access::Api.new.favorites_delete location_key, .merge(favorite_type: 'locations') end |
.delete_offer(offer_key, options = {}) ⇒ Object
75 76 77 |
# File 'lib/access/favorite.rb', line 75 def self.delete_offer(offer_key, = {}) Access::Api.new.favorites_delete offer_key, .merge(favorite_type: 'offers') end |
.delete_store(store_key, options = {}) ⇒ Object
83 84 85 |
# File 'lib/access/favorite.rb', line 83 def self.delete_store(store_key, = {}) Access::Api.new.favorites_delete store_key, .merge(favorite_type: 'stores') end |
.find(offer_key, options = {}) ⇒ Object
39 40 41 |
# File 'lib/access/favorite.rb', line 39 def self.find(offer_key, = {}) Access::Api.new.favorites_find offer_key, end |
.find_location(location_key, options = {}) ⇒ Object
47 48 49 |
# File 'lib/access/favorite.rb', line 47 def self.find_location(location_key, = {}) Access::Api.new.favorites_find location_key, .merge(favorite_type: 'locations') end |
.find_offer(offer_key, options = {}) ⇒ Object
43 44 45 |
# File 'lib/access/favorite.rb', line 43 def self.find_offer(offer_key, = {}) Access::Api.new.favorites_find offer_key, .merge(favorite_type: 'offers') end |
.find_store(store_key, options = {}) ⇒ Object
51 52 53 |
# File 'lib/access/favorite.rb', line 51 def self.find_store(store_key, = {}) Access::Api.new.favorites_find store_key, .merge(favorite_type: 'stores') end |
.process_batch(chunk) ⇒ Object
4 5 6 |
# File 'lib/access/favorite.rb', line 4 def self.process_batch(chunk) chunk.map { |favorite| new(favorite) } end |
.search(options = {}) ⇒ Object
23 24 25 |
# File 'lib/access/favorite.rb', line 23 def self.search( = {}) Access::Api.new.favorites_search end |
.search_locations(options = {}) ⇒ Object
31 32 33 |
# File 'lib/access/favorite.rb', line 31 def self.search_locations( = {}) Access::Api.new.favorites_search .merge(favorite_type: 'locations') end |
.search_offers(options = {}) ⇒ Object
27 28 29 |
# File 'lib/access/favorite.rb', line 27 def self.search_offers( = {}) Access::Api.new.favorites_search .merge(favorite_type: 'offers') end |
.search_stores(options = {}) ⇒ Object
35 36 37 |
# File 'lib/access/favorite.rb', line 35 def self.search_stores( = {}) Access::Api.new.favorites_search .merge(favorite_type: 'stores') end |
Instance Method Details
#resource ⇒ Object
19 20 21 |
# File 'lib/access/favorite.rb', line 19 def resource self.send(self.favorite_type) end |