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.7.2 lib/intercom/traits/incrementable_attributes.rb
intercom-3.7.1 lib/intercom/traits/incrementable_attributes.rb
intercom-3.7.0 lib/intercom/traits/incrementable_attributes.rb
intercom-3.6.2 lib/intercom/traits/incrementable_attributes.rb
intercom-3.6.1 lib/intercom/traits/incrementable_attributes.rb
intercom-3.6.0 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.26 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.25 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.24 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.23 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.22 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.21 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.20 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.19 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.17 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.16 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.15 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.14 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.12 lib/intercom/traits/incrementable_attributes.rb
intercom-3.5.11 lib/intercom/traits/incrementable_attributes.rb