Class: Parse::Pointer
- Inherits:
-
Object
- Object
- Parse::Pointer
- Defined in:
- lib/parse/datatypes.rb
Overview
Pointer
Instance Attribute Summary collapse
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#parse_object_id ⇒ Object
(also: #id)
Returns the value of attribute parse_object_id.
Instance Method Summary collapse
- #as_json(*a) ⇒ Object
- #eql?(other) ⇒ Boolean (also: #==)
-
#get ⇒ Object
Retrieve the Parse object referenced by this pointer.
- #hash ⇒ Object
-
#initialize(data) ⇒ Pointer
constructor
A new instance of Pointer.
-
#pointer ⇒ Object
make it easier to deal with the ambiguity of whether you’re passed a pointer or object.
- #to_json(*a) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(data) ⇒ Pointer
Returns a new instance of Pointer.
13 14 15 16 |
# File 'lib/parse/datatypes.rb', line 13 def initialize(data) @class_name = data[Protocol::KEY_CLASS_NAME] @parse_object_id = data[Protocol::KEY_OBJECT_ID] end |
Instance Attribute Details
#class_name ⇒ Object
Returns the value of attribute class_name.
10 11 12 |
# File 'lib/parse/datatypes.rb', line 10 def class_name @class_name end |
#parse_object_id ⇒ Object Also known as: id
Returns the value of attribute parse_object_id.
9 10 11 |
# File 'lib/parse/datatypes.rb', line 9 def parse_object_id @parse_object_id end |
Instance Method Details
#as_json(*a) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/parse/datatypes.rb', line 35 def as_json(*a) { Protocol::KEY_TYPE => Protocol::TYPE_POINTER, Protocol::KEY_CLASS_NAME => @class_name, Protocol::KEY_OBJECT_ID => @parse_object_id } end |
#eql?(other) ⇒ Boolean Also known as: ==
23 24 25 26 27 |
# File 'lib/parse/datatypes.rb', line 23 def eql?(other) self.class.equal?(other.class) && class_name == other.class_name && parse_object_id == other.parse_object_id end |
#get ⇒ Object
Retrieve the Parse object referenced by this pointer.
48 49 50 |
# File 'lib/parse/datatypes.rb', line 48 def get Parse.get @class_name, @parse_object_id if @parse_object_id end |
#hash ⇒ Object
31 32 33 |
# File 'lib/parse/datatypes.rb', line 31 def hash class_name.hash ^ parse_object_id.hash end |
#pointer ⇒ Object
make it easier to deal with the ambiguity of whether you’re passed a pointer or object
19 20 21 |
# File 'lib/parse/datatypes.rb', line 19 def pointer self end |
#to_json(*a) ⇒ Object
43 44 45 |
# File 'lib/parse/datatypes.rb', line 43 def to_json(*a) as_json.to_json(*a) end |
#to_s ⇒ Object
52 53 54 |
# File 'lib/parse/datatypes.rb', line 52 def to_s "#{@class_name}:#{@parse_object_id}" end |