Module: Intercom::Traits::IncrementableAttributes

Included in:
Company, User, Visitor
Defined in:
lib/intercom/traits/incrementable_attributes.rb

Instance Method Summary collapse

Instance Method Details

#decrement(key, value = 1) ⇒ Object


11
12
13
14
# File 'lib/intercom/traits/incrementable_attributes.rb', line 11

def decrement(key, value=1)
  existing_value = self.custom_attributes[key] || 0
  self.custom_attributes[key] = existing_value - value
end

#increment(key, value = 1) ⇒ Object


5
6
7
8
9
# File 'lib/intercom/traits/incrementable_attributes.rb', line 5

def increment(key, value=1)
  existing_value = self.custom_attributes[key]
  existing_value ||= 0
  self.custom_attributes[key] = existing_value + value
end