Sha256: c22903d12158271853f1bc0ec7df28dd0e4e108700a526e31c58fe6f6aa8f48b

Contents?: true

Size: 814 Bytes

Versions: 23

Compression:

Stored size: 814 Bytes

Contents

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

    def search(query, options = {})
      type = self.to_s.underscore.split('/').last
      FbGraph::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

23 entries across 23 versions & 2 rubygems

Version Path
fb_graph-1.2.1 lib/fb_graph/searchable.rb
fb_graph-1.2.0 lib/fb_graph/searchable.rb
fb_graph-1.1.7 lib/fb_graph/searchable.rb
fb_graph-1.1.6 lib/fb_graph/searchable.rb
fb_graph-1.1.5 lib/fb_graph/searchable.rb
fb_graph-1.1.4 lib/fb_graph/searchable.rb
fb_graph-1.1.3 lib/fb_graph/searchable.rb
fb_graph-1.1.2 lib/fb_graph/searchable.rb
fb_graph-1.1.1 lib/fb_graph/searchable.rb
fb_graph-1.1.0 lib/fb_graph/searchable.rb
fb_graph-1.0.7 lib/fb_graph/searchable.rb
fb_graph-1.0.6 lib/fb_graph/searchable.rb
fb_graph-1.0.5 lib/fb_graph/searchable.rb
palidanx-fb_graph-1.0.4 lib/fb_graph/searchable.rb
fb_graph-1.0.4 lib/fb_graph/searchable.rb
fb_graph-1.0.3 lib/fb_graph/searchable.rb
fb_graph-1.0.2 lib/fb_graph/searchable.rb
fb_graph-1.0.1 lib/fb_graph/searchable.rb
fb_graph-1.0.0 lib/fb_graph/searchable.rb
fb_graph-0.8.0 lib/fb_graph/searchable.rb