Class: Access::Favorite
- Inherits:
-
Object
- Object
- Access::Favorite
- Defined in:
- lib/access/favorite.rb
Class Method Summary collapse
-
.create(offer_key, options = {}) ⇒ Object
create.
- .create_location(location_key, options = {}) ⇒ Object
- .create_offer(offer_key, options = {}) ⇒ Object
- .create_store(store_key, options = {}) ⇒ Object
-
.delete(offer_key, options = {}) ⇒ Object
delete.
- .delete_location(location_key, options = {}) ⇒ Object
- .delete_offer(offer_key, options = {}) ⇒ Object
- .delete_store(store_key, options = {}) ⇒ Object
-
.find(resource_id, options = {}) ⇒ Object
find / show.
- .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 / index.
- .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
create
62 63 64 65 |
# File 'lib/access/favorite.rb', line 62 def self.create(offer_key, = {}) # must pass in a favorite_type Access::Api.new.favorites_create offer_key, end |
.create_location(location_key, options = {}) ⇒ Object
71 72 73 |
# File 'lib/access/favorite.rb', line 71 def self.create_location(location_key, = {}) Access::Api.new.favorites_create location_key, .merge(favorite_type: 'locations') end |
.create_offer(offer_key, options = {}) ⇒ Object
67 68 69 |
# File 'lib/access/favorite.rb', line 67 def self.create_offer(offer_key, = {}) Access::Api.new.favorites_create offer_key, .merge(favorite_type: 'offers') end |
.create_store(store_key, options = {}) ⇒ Object
75 76 77 |
# File 'lib/access/favorite.rb', line 75 def self.create_store(store_key, = {}) Access::Api.new.favorites_create store_key, .merge(favorite_type: 'stores') end |
.delete(offer_key, options = {}) ⇒ Object
delete
81 82 83 |
# File 'lib/access/favorite.rb', line 81 def self.delete(offer_key, = {}) Access::Api.new.favorites_delete offer_key, end |
.delete_location(location_key, options = {}) ⇒ Object
89 90 91 |
# File 'lib/access/favorite.rb', line 89 def self.delete_location(location_key, = {}) Access::Api.new.favorites_delete location_key, .merge(favorite_type: 'locations') end |
.delete_offer(offer_key, options = {}) ⇒ Object
85 86 87 |
# File 'lib/access/favorite.rb', line 85 def self.delete_offer(offer_key, = {}) Access::Api.new.favorites_delete offer_key, .merge(favorite_type: 'offers') end |
.delete_store(store_key, options = {}) ⇒ Object
93 94 95 |
# File 'lib/access/favorite.rb', line 93 def self.delete_store(store_key, = {}) Access::Api.new.favorites_delete store_key, .merge(favorite_type: 'stores') end |
.find(resource_id, options = {}) ⇒ Object
find / show
43 44 45 46 |
# File 'lib/access/favorite.rb', line 43 def self.find(resource_id, = {}) # must pass in a favorite_type Access::Api.new.favorites_find resource_id, end |
.find_location(location_key, options = {}) ⇒ Object
52 53 54 |
# File 'lib/access/favorite.rb', line 52 def self.find_location(location_key, = {}) Access::Api.new.favorites_find location_key, .merge(favorite_type: 'locations') end |
.find_offer(offer_key, options = {}) ⇒ Object
48 49 50 |
# File 'lib/access/favorite.rb', line 48 def self.find_offer(offer_key, = {}) Access::Api.new.favorites_find offer_key, .merge(favorite_type: 'offers') end |
.find_store(store_key, options = {}) ⇒ Object
56 57 58 |
# File 'lib/access/favorite.rb', line 56 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
search / index
25 26 27 |
# File 'lib/access/favorite.rb', line 25 def self.search( = {}) Access::Api.new.favorites_search end |
.search_locations(options = {}) ⇒ Object
33 34 35 |
# File 'lib/access/favorite.rb', line 33 def self.search_locations( = {}) Access::Api.new.favorites_search .merge(favorite_type: 'locations') end |
.search_offers(options = {}) ⇒ Object
29 30 31 |
# File 'lib/access/favorite.rb', line 29 def self.search_offers( = {}) Access::Api.new.favorites_search .merge(favorite_type: 'offers') end |
.search_stores(options = {}) ⇒ Object
37 38 39 |
# File 'lib/access/favorite.rb', line 37 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 |