Class: Parse::Pointer
- Inherits:
-
Object
- Object
- Parse::Pointer
- Defined in:
- lib/parse/pointer.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
-
#initialize(hash, parent = nil) ⇒ Pointer
constructor
A new instance of Pointer.
- #load ⇒ Object
- #to_h ⇒ Object
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(hash, parent = nil) ⇒ Pointer
Returns a new instance of Pointer.
6 7 8 9 10 11 12 13 |
# File 'lib/parse/pointer.rb', line 6 def initialize hash, parent=nil @raw_hash = hash @parent_object = parent if @raw_hash.has_key? 'body' @object = pointed_parse_class.new @raw_hash['body'] end end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
4 5 6 |
# File 'lib/parse/pointer.rb', line 4 def object @object end |
Instance Method Details
#load ⇒ Object
15 16 17 |
# File 'lib/parse/pointer.rb', line 15 def load @object ||= pointed_parse_class.find_by_id @raw_hash['objectId'] end |
#to_h ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/parse/pointer.rb', line 19 def to_h { "__type" => "Pointer", "className" => "#{@raw_hash['className']}", "objectId" => "#{@raw_hash['objectId']}" } end |
#to_json(*args) ⇒ Object
27 28 29 |
# File 'lib/parse/pointer.rb', line 27 def to_json *args to_h.to_json end |