Sha256: 112a431d8584bcb5c34c3154cbe2e2b553f52dcd90cb538a27c6b78dcaa2eddd

Contents?: true

Size: 1.21 KB

Versions: 20

Compression:

Stored size: 1.21 KB

Contents

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
adparlor-facebook-0.8.2 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.8.0 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.7.9 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.7.8 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.7.7 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.7.6 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.7.5 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.7.4 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.7.3 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.7.2 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.7.1 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.7.0 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.6.6 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.6.5 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.6.4 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.6.3 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.6.2 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.6.1 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.6.0 lib/adparlor/facebook/graph_api/collection_proxy.rb
adparlor-facebook-0.5.9 lib/adparlor/facebook/graph_api/collection_proxy.rb