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.
Class Method Summary collapse
Instance Method Summary collapse
- #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.
- #new? ⇒ Boolean
-
#pointer ⇒ Object
make it easier to deal with the ambiguity of whether you’re passed a pointer or object.
- #to_h(*a) ⇒ Object (also: #as_json)
- #to_json(*a) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(data) ⇒ Pointer
Returns a new instance of Pointer.
20 21 22 23 |
# File 'lib/parse/datatypes.rb', line 20 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 |
Class Method Details
.make(class_name, object_id) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/parse/datatypes.rb', line 13 def self.make(class_name, object_id) Pointer.new( Protocol::KEY_CLASS_NAME => class_name, Protocol::KEY_OBJECT_ID => object_id ) end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
30 31 32 |
# File 'lib/parse/datatypes.rb', line 30 def eql?(other) Parse.object_pointer_equality?(self, other) end |
#get ⇒ Object
Retrieve the Parse object referenced by this pointer.
58 59 60 |
# File 'lib/parse/datatypes.rb', line 58 def get Parse.get @class_name, @parse_object_id if @parse_object_id end |
#hash ⇒ Object
36 37 38 |
# File 'lib/parse/datatypes.rb', line 36 def hash Parse.object_pointer_hash(self) end |
#new? ⇒ Boolean
40 41 42 |
# File 'lib/parse/datatypes.rb', line 40 def new? false end |
#pointer ⇒ Object
make it easier to deal with the ambiguity of whether you’re passed a pointer or object
26 27 28 |
# File 'lib/parse/datatypes.rb', line 26 def pointer self end |
#to_h(*a) ⇒ Object Also known as: as_json
44 45 46 47 48 49 50 |
# File 'lib/parse/datatypes.rb', line 44 def to_h(*a) { Protocol::KEY_TYPE => Protocol::TYPE_POINTER, Protocol::KEY_CLASS_NAME => @class_name, Protocol::KEY_OBJECT_ID => @parse_object_id } end |
#to_json(*a) ⇒ Object
53 54 55 |
# File 'lib/parse/datatypes.rb', line 53 def to_json(*a) to_h.to_json(*a) end |
#to_s ⇒ Object
62 63 64 |
# File 'lib/parse/datatypes.rb', line 62 def to_s "#{@class_name}:#{@parse_object_id}" end |