Sha256: 1f9c254deeece6f8730c6f5333a53f9a2fc3d90c1540df1bbc08fe49df0e9052

Contents?: true

Size: 438 Bytes

Versions: 46

Compression:

Stored size: 438 Bytes

Contents

module Intercom
  module Traits
    module IncrementableAttributes

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

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

    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
intercom-3.5.10 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.9 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.8 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.7 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.6 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.5 lib/intercom/traits/incrementable_attributes.rb