Module: FbGraph::Searchable

Included in:
Checkin, Event, Group, Page, Post, User
Defined in:
lib/fb_graph/searchable.rb,
lib/fb_graph/searchable/result.rb

Defined Under Namespace

Classes: Result

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.search(query, options = {}) {|collection| ... } ⇒ Object

Yields:

  • (collection)


3
4
5
6
7
8
9
10
# File 'lib/fb_graph/searchable.rb', line 3

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

Instance Method Details

#search(query, options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/fb_graph/searchable.rb', line 12

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