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.



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

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

Instance Attribute Details

#objectsObject

Returns the value of attribute objects.



217
218
219
# File 'lib/parse/datatypes.rb', line 217

def objects
  @objects
end

#operationObject

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



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

def operation
  @operation
end

Instance Method Details

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

Returns:

  • (Boolean)


224
225
226
227
228
# File 'lib/parse/datatypes.rb', line 224

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

#hashObject



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

def hash
  operation.hash ^ objects.hash
end

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



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

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

#to_json(*a) ⇒ Object



244
245
246
# File 'lib/parse/datatypes.rb', line 244

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