Sha256: 62b5c6aa95b8eff3c918740e0313b7de937711cde28b52442b8c7868eb5a58fc

Contents?: true

Size: 771 Bytes

Versions: 4

Compression:

Stored size: 771 Bytes

Contents

module FbGraph
  module Connections
    module Insights
      def insights(options = {})
        options[:access_token] ||= self.access_token
        options[:access_token] ||= get_access_token(options[:secret]) if respond_to?(:get_access_token)
        insights = self.connection(:insights, options.merge(:connection_scope => connection_scope(options)))
        insights.map! do |insight|
          Insight.new(insight[:id], insight.merge(:access_token => options[:access_token]))
        end
      end

      private

      def connection_scope(options)
        if metrics = options.delete(:metrics)
          File.join([metrics, options.delete(:period)].compact.collect(&:to_s))
        else
          options[:connection_scope]
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fb_graph-1.8.5 lib/fb_graph/connections/insights.rb
fb_graph-1.8.4 lib/fb_graph/connections/insights.rb
fb_graph-1.8.3 lib/fb_graph/connections/insights.rb
fb_graph-1.8.2 lib/fb_graph/connections/insights.rb