module Adparlor module Facebook module GraphApi class CollectionProxy def initialize(klass, path, access_token, data = nil, options = {}) @klass = klass @path = path @access_token = access_token @options = options @all = Array(data).collect { |attributes| @klass.new(attributes) } if data end def all(options = {}) options.merge!(access_token: @access_token) unless options[:access_token] options.merge!(@options) if @options.any? @all ||= @klass.get(@path, options) end def create(attributes = {}, options = {}) options.merge!(access_token: @access_token) unless options[:access_token] @klass.new(attributes).create(@path, options) end def destroy(attributes = {}, options = {}) options.merge!(access_token: @access_token) unless options[:access_token] @klass.new(attributes).destroy(@path, options) end def update(attributes = {}, options = {}) options.merge!(access_token: @access_token) unless options[:access_token] @klass.new(attributes).update(@path, options) end end end end end