Class: Access::Offer
- Inherits:
-
Object
- Object
- Access::Offer
- Defined in:
- lib/access/offer.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Class Method Summary collapse
- .find(offer_key, options = {}) ⇒ Object
- .find_uses_remaining(offer_key, options = {}) ⇒ Object
- .process_batch(chunk) ⇒ Object
- .search(options = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(values) ⇒ Offer
constructor
A new instance of Offer.
Constructor Details
#initialize(values) ⇒ Offer
Returns a new instance of Offer.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/access/offer.rb', line 21 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 @categories = Access::Category.process_batch(@categories) if @categories @links = Access::Link.new(@links) if @links @offer_store = Access::Store.new(@offer_store) if @offer_store @offer_uses_remaining = Access::Redemption.new(@offer_uses_remaining) if @offer_uses_remaining end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
3 4 5 |
# File 'lib/access/offer.rb', line 3 def location @location end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
3 4 5 |
# File 'lib/access/offer.rb', line 3 def store @store end |
Class Method Details
.find(offer_key, options = {}) ⇒ Object
9 10 11 |
# File 'lib/access/offer.rb', line 9 def self.find(offer_key, = {}) Access::Api.new.find_offer offer_key, end |
.find_uses_remaining(offer_key, options = {}) ⇒ Object
13 14 15 |
# File 'lib/access/offer.rb', line 13 def self.find_uses_remaining(offer_key, = {}) Access::Api.new.find_offer_uses_remaining offer_key, end |
.process_batch(chunk) ⇒ Object
17 18 19 |
# File 'lib/access/offer.rb', line 17 def self.process_batch(chunk) chunk.map { |offer| new(offer) } end |
.search(options = {}) ⇒ Object
5 6 7 |
# File 'lib/access/offer.rb', line 5 def self.search( = {}) Access::Api.new.search_offers end |