Class: FBGraph::Result
- Inherits:
-
Object
- Object
- FBGraph::Result
- Includes:
- Comparable, Enumerable
- Defined in:
- lib/fbgraph/result.rb
Instance Attribute Summary (collapse)
-
- (Object) data
Returns the value of attribute data.
-
- (Object) params
Returns the value of attribute params.
-
- (Object) unparsed
Returns the value of attribute unparsed.
Instance Method Summary (collapse)
-
- (Object) <=>(other)
Implement Comparable.
-
- (Object) each(&block)
Implement enumerable.
-
- (Result) initialize(result, params = {}, &block)
constructor
A new instance of Result.
- - (Object) metadata
- - (Object) method_missing(method, *args, &block)
- - (Object) paging
Constructor Details
- (Result) initialize(result, params = {}, &block)
A new instance of Result
8 9 10 11 12 13 14 |
# File 'lib/fbgraph/result.rb', line 8 def initialize(result, params = {}, &block) result = result.respond_to?(:body) ? result.body : result.to_s @data = Hashie::Mash.new(JSON.parse(result)) rescue result @unparsed = result @params = params.symbolize_keys self end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
- (Object) method_missing(method, *args, &block)
37 38 39 |
# File 'lib/fbgraph/result.rb', line 37 def method_missing(method, *args, &block) data.send(method, *args, &block) rescue super(method, *args, &block) end |
Instance Attribute Details
- (Object) data
Returns the value of attribute data
6 7 8 |
# File 'lib/fbgraph/result.rb', line 6 def data @data end |
- (Object) params
Returns the value of attribute params
6 7 8 |
# File 'lib/fbgraph/result.rb', line 6 def params @params end |
- (Object) unparsed
Returns the value of attribute unparsed
6 7 8 |
# File 'lib/fbgraph/result.rb', line 6 def unparsed @unparsed end |
Instance Method Details
- (Object) <=>(other)
Implement Comparable
32 33 34 |
# File 'lib/fbgraph/result.rb', line 32 def <=>(other) (data <=> other.data) rescue 0 end |
- (Object) each(&block)
Implement enumerable
25 26 27 28 |
# File 'lib/fbgraph/result.rb', line 25 def each(&block) return nil if data.blank? data.each(&block) end |
- (Object) metadata
20 21 22 |
# File 'lib/fbgraph/result.rb', line 20 def data. end |
- (Object) paging
16 17 18 |
# File 'lib/fbgraph/result.rb', line 16 def paging data.paging end |