Module: FbGraph::Searchable
- Defined in:
- lib/fb_graph/searchable.rb,
lib/fb_graph/searchable/result.rb
Defined Under Namespace
Classes: Result
Class Method Summary collapse
- .search(query, options = {}) {|collection| ... } ⇒ Object
-
.search_query_param ⇒ Object
The majority of Graph API searches use ‘q’ but some, like AdKeywordSuggestion use an alternate search query param.
Instance Method Summary collapse
Class Method Details
.search(query, options = {}) {|collection| ... } ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/fb_graph/searchable.rb', line 3 def self.search(query, = {}) klass = .delete(:class) || Searchable query_param = klass.search_query_param collection = Collection.new( Node.new(:search).send(:get, .merge(query_param.to_sym => query)) ) yield collection if block_given? Searchable::Result.new(query, klass, .merge(:collection => collection)) end |
.search_query_param ⇒ Object
The majority of Graph API searches use ‘q’ but some, like AdKeywordSuggestion use an alternate search query param
26 27 28 |
# File 'lib/fb_graph/searchable.rb', line 26 def self.search_query_param :q end |
Instance Method Details
#search(query, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fb_graph/searchable.rb', line 13 def search(query, = {}) type = self.to_s.underscore.split('/').last.gsub("_", "") Searchable.search(query, .merge(:type => type, :class => self)) do |collection| collection.map! do |obj| self.new(obj[:id], obj.merge( :access_token => [:access_token] )) end end end |