Sha256: f870502b9cde42659405227c9a3b77405366ff276bdbcddf308b485c20b6f607

Contents?: true

Size: 769 Bytes

Versions: 42

Compression:

Stored size: 769 Bytes

Contents

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

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

require 'fb_graph/searchable/result'

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
fb_graph-1.8.0 lib/fb_graph/searchable.rb
fb_graph-1.8.0.alpha2 lib/fb_graph/searchable.rb
fb_graph-1.7.5 lib/fb_graph/searchable.rb
fb_graph-1.8.0.alpha lib/fb_graph/searchable.rb
fb_graph-1.7.4 lib/fb_graph/searchable.rb
fb_graph-1.7.3 lib/fb_graph/searchable.rb
fb_graph-1.7.2 lib/fb_graph/searchable.rb
fb_graph-1.7.1 lib/fb_graph/searchable.rb
fb_graph-1.7.0 lib/fb_graph/searchable.rb
fb_graph-1.7.0.alpha2 lib/fb_graph/searchable.rb
fb_graph-1.6.9 lib/fb_graph/searchable.rb
fb_graph-1.7.0.alpha lib/fb_graph/searchable.rb
fb_graph-1.6.8 lib/fb_graph/searchable.rb
fb_graph-1.6.7 lib/fb_graph/searchable.rb
fb_graph-1.6.5 lib/fb_graph/searchable.rb
fb_graph-1.6.4 lib/fb_graph/searchable.rb
fb_graph-1.6.3 lib/fb_graph/searchable.rb
fb_graph-1.6.2 lib/fb_graph/searchable.rb
fb_graph-1.6.1 lib/fb_graph/searchable.rb
fb_graph-1.6.0 lib/fb_graph/searchable.rb