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.
-
#parse_object_id ⇒ Object
readonly
Returns the value of attribute parse_object_id.
Instance Method Summary collapse
-
#initialize(hash, parent = nil) ⇒ Pointer
constructor
A new instance of Pointer.
- #load ⇒ Object
-
#load! ⇒ Object
TODO: should be refactored.
- #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 14 |
# File 'lib/parse/pointer.rb', line 6 def initialize hash, parent=nil @raw_hash = hash @parse_object_id = hash['objectId'] @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 |
#parse_object_id ⇒ Object (readonly)
Returns the value of attribute parse_object_id.
4 5 6 |
# File 'lib/parse/pointer.rb', line 4 def parse_object_id @parse_object_id end |
Instance Method Details
#load ⇒ Object
16 17 18 |
# File 'lib/parse/pointer.rb', line 16 def load @object ||= pointed_parse_class.find_by_id @raw_hash['objectId'] end |
#load! ⇒ Object
TODO: should be refactored
21 22 23 |
# File 'lib/parse/pointer.rb', line 21 def load! @object ||= pointed_parse_class.find_by_id! @raw_hash['objectId'] end |
#to_h ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/parse/pointer.rb', line 25 def to_h { "__type" => "Pointer", "className" => "#{@raw_hash['className']}", "objectId" => "#{@raw_hash['objectId']}" } end |
#to_json(*args) ⇒ Object
33 34 35 |
# File 'lib/parse/pointer.rb', line 33 def to_json *args to_h.to_json end |