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-4.2.1 lib/intercom/traits/incrementable_attributes.rb
intercom-4.2.0 lib/intercom/traits/incrementable_attributes.rb
intercom-4.1.3 lib/intercom/traits/incrementable_attributes.rb
intercom-4.1.2 lib/intercom/traits/incrementable_attributes.rb
intercom-4.1.1 lib/intercom/traits/incrementable_attributes.rb
intercom-4.1.0 lib/intercom/traits/incrementable_attributes.rb
intercom-4.0.1 lib/intercom/traits/incrementable_attributes.rb
intercom-4.0.0 lib/intercom/traits/incrementable_attributes.rb
intercom-3.9.5 lib/intercom/traits/incrementable_attributes.rb
intercom-3.9.4 lib/intercom/traits/incrementable_attributes.rb
intercom-3.9.3 lib/intercom/traits/incrementable_attributes.rb
intercom-3.9.2 lib/intercom/traits/incrementable_attributes.rb
intercom-3.9.0 lib/intercom/traits/incrementable_attributes.rb
intercom-3.8.1 lib/intercom/traits/incrementable_attributes.rb
intercom-3.8.0 lib/intercom/traits/incrementable_attributes.rb
intercom-3.7.7 lib/intercom/traits/incrementable_attributes.rb
intercom-3.7.6 lib/intercom/traits/incrementable_attributes.rb
intercom-3.7.5 lib/intercom/traits/incrementable_attributes.rb
intercom-3.7.4 lib/intercom/traits/incrementable_attributes.rb
intercom-3.7.3 lib/intercom/traits/incrementable_attributes.rb