module Access class Campaign def self.search(options = {}) Access::Api.new.search_campaigns options end def self.find(campaign_key, options = {}) Access::Api.new.find_campaign campaign_key, options end def self.process_batch(chunk) chunk.map { |campaign| new(campaign) } 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 @spots = Access::Spot.process_batch(@spots) if @spots @spot_list = Access::Spot.process_batch(@spot_list) if @spot_list @channels = Access::Channel.process_batch(@channels) if @channels @channel_list = Access::Channel.process_batch(@channel_list) if @channel_list @links = Access::Link.process_batch(@links) if @links end end end