Class: Access::Spot
- Inherits:
-
Object
- Object
- Access::Spot
- Defined in:
- lib/access/spot.rb
Class Method Summary collapse
- .find(spot_key, options = {}) ⇒ Object
- .process_batch(chunk) ⇒ Object
- .search_by_campaign(campaign_key, options = {}) ⇒ Object
- .search_by_channel(channel_key, options = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(values) ⇒ Spot
constructor
A new instance of Spot.
Constructor Details
#initialize(values) ⇒ Spot
Returns a new instance of Spot.
20 21 22 23 24 25 26 27 |
# File 'lib/access/spot.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 @offer_resource = Access::Offer.new(@offer_resource) if @offer_resource @links = Access::Link.process_batch(@links) if @links end |
Class Method Details
.find(spot_key, options = {}) ⇒ Object
12 13 14 |
# File 'lib/access/spot.rb', line 12 def self.find(spot_key, = {}) Access::Api.new.find_spot spot_key, end |
.process_batch(chunk) ⇒ Object
16 17 18 |
# File 'lib/access/spot.rb', line 16 def self.process_batch(chunk) chunk.map { |spot| new(spot) } end |
.search_by_campaign(campaign_key, options = {}) ⇒ Object
8 9 10 |
# File 'lib/access/spot.rb', line 8 def self.search_by_campaign(campaign_key, = {}) Access::Api.new.search_spots_by_campaign campaign_key, end |
.search_by_channel(channel_key, options = {}) ⇒ Object
4 5 6 |
# File 'lib/access/spot.rb', line 4 def self.search_by_channel(channel_key, = {}) Access::Api.new.search_spots_by_channel channel_key, end |