Class: Parse::Increment

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

Overview

Increment (or decrement) counter parseplatform.github.io/docs/rest/guide/#counters

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount) ⇒ Increment

Returns a new instance of Increment.



177
178
179
# File 'lib/parse/datatypes.rb', line 177

def initialize(amount)
  @amount = amount
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



175
176
177
# File 'lib/parse/datatypes.rb', line 175

def amount
  @amount
end

Instance Method Details

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

Returns:

  • (Boolean)


181
182
183
184
# File 'lib/parse/datatypes.rb', line 181

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

#hashObject



187
188
189
# File 'lib/parse/datatypes.rb', line 187

def hash
  amount.hash
end

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



191
192
193
194
195
196
# File 'lib/parse/datatypes.rb', line 191

def to_h(*_a)
  {
    Protocol::KEY_OP => Protocol::KEY_INCREMENT,
    Protocol::KEY_AMOUNT => @amount
  }
end

#to_json(*a) ⇒ Object



199
200
201
# File 'lib/parse/datatypes.rb', line 199

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