Sha256: 50a5ca85f99f2052076723cec9b9e49fab6b22123df035c7df7119682f4afadd

Contents?: true

Size: 866 Bytes

Versions: 28

Compression:

Stored size: 866 Bytes

Contents

module FbGraph2
  module Searchable
    def self.search(query, access_token, options = {})
      klass = options.delete(:class) || Searchable
      collection = Collection.new(
        Node.new(:search).authenticate(
          access_token
        ).send(:get, options.merge(q: query))
      )
      yield collection if block_given?
      Searchable::Result.new(query, access_token, klass, options.merge(:collection => collection))
    end

    def search(query, access_token, options = {})
      type = self.to_s.split('::').last.underscore
      Searchable.search(query, access_token, options.merge(:type => type, :class => self)) do |collection|
        collection.map! do |obj|
          self.new(obj[:id], obj.merge(
            :access_token => options[:access_token]
          ))
        end
      end
    end
  end
end

require 'fb_graph2/searchable/result'

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
fb_graph2-1.3.0 lib/fb_graph2/searchable.rb
fb_graph2-1.2.0 lib/fb_graph2/searchable.rb
fb_graph2-1.1.1 lib/fb_graph2/searchable.rb
fb_graph2-1.1.0 lib/fb_graph2/searchable.rb
fb_graph2-1.0.1 lib/fb_graph2/searchable.rb
fb_graph2-1.0.0 lib/fb_graph2/searchable.rb
fb_graph2-0.9.1 lib/fb_graph2/searchable.rb
fb_graph2-0.9.0 lib/fb_graph2/searchable.rb
fb_graph2-0.8.0 lib/fb_graph2/searchable.rb
fb_graph2-0.7.9 lib/fb_graph2/searchable.rb
fb_graph2-0.7.8 lib/fb_graph2/searchable.rb
fb_graph2-0.7.7 lib/fb_graph2/searchable.rb
fb_graph2-0.7.6 lib/fb_graph2/searchable.rb
fb_graph2-0.7.5 lib/fb_graph2/searchable.rb
fb_graph2-0.7.4 lib/fb_graph2/searchable.rb
fb_graph2-0.7.3 lib/fb_graph2/searchable.rb
fb_graph2-0.7.2 lib/fb_graph2/searchable.rb
fb_graph2-0.7.1 lib/fb_graph2/searchable.rb
fb_graph2-0.7.0 lib/fb_graph2/searchable.rb
fb_graph2-0.6.2 lib/fb_graph2/searchable.rb