Class: Opium::Pointer

Inherits:
Object show all
Defined in:
lib/opium/extensions/pointer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Pointer

Returns a new instance of Pointer.



3
4
5
6
7
# File 'lib/opium/extensions/pointer.rb', line 3

def initialize( attributes = {} )
  self.class_name = attributes[:class_name] || attributes[:model_name] || (attributes[:class] || attributes[:model]).model_name
  self.class_name = self.class_name.name if self.class_name.respond_to?(:name)
  self.id = attributes[:id]
end

Instance Attribute Details

#class_nameObject Also known as: model_name

Returns the value of attribute class_name.



9
10
11
# File 'lib/opium/extensions/pointer.rb', line 9

def class_name
  @class_name
end

#idObject

Returns the value of attribute id.



9
10
11
# File 'lib/opium/extensions/pointer.rb', line 9

def id
  @id
end

Instance Method Details

#to_parseObject



12
13
14
# File 'lib/opium/extensions/pointer.rb', line 12

def to_parse
  { __type: 'Pointer', className: class_name, objectId: id }.with_indifferent_access
end