Class: Parse::ArrayOp

Inherits:
Object
  • Object
show all
Defined in:
lib/parse/datatypes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operation, objects) ⇒ ArrayOp

Returns a new instance of ArrayOp.



214
215
216
217
# File 'lib/parse/datatypes.rb', line 214

def initialize(operation, objects)
  @operation = operation
  @objects = objects
end

Instance Attribute Details

#objectsObject

Returns the value of attribute objects.



212
213
214
# File 'lib/parse/datatypes.rb', line 212

def objects
  @objects
end

#operationObject

‘{“myArray”: {“__op”: “Add”, “objects”: [“something”, “something else”] } }’



211
212
213
# File 'lib/parse/datatypes.rb', line 211

def operation
  @operation
end

Instance Method Details

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


219
220
221
222
223
# File 'lib/parse/datatypes.rb', line 219

def eql?(other)
  self.class.equal?(other.class) &&
    operation == other.operation &&
    objects == other.objects
end

#hashObject



227
228
229
# File 'lib/parse/datatypes.rb', line 227

def hash
  operation.hash ^ objects.hash
end

#to_h(*a) ⇒ Object Also known as: as_json



231
232
233
234
235
236
# File 'lib/parse/datatypes.rb', line 231

def to_h(*a)
  {
      Protocol::KEY_OP => operation,
      Protocol::KEY_OBJECTS => @objects
  }
end

#to_json(*a) ⇒ Object



239
240
241
# File 'lib/parse/datatypes.rb', line 239

def to_json(*a)
  to_h.to_json(*a)
end