Sha256: 999fa6fc538fde933f23570a13808200a004d079305785f4fb1e18193962f5a2

Contents?: true

Size: 756 Bytes

Versions: 79

Compression:

Stored size: 756 Bytes

Contents

require 'set'

module Intercom
  module Traits
    module DirtyTracking

      def reset_changed_fields!
        @changed_fields = Set.new
      end

      def mark_fields_as_changed!(field_names)
        @changed_fields ||= Set.new
        field_names.each do |attr|
          @changed_fields.add(attr.to_s)
        end
      end

      def mark_field_as_changed!(field_name)
        @changed_fields ||= Set.new
        @changed_fields.add(field_name.to_s)
      end

      def field_changed?(field_name)
        @changed_fields ||= Set.new
        @changed_fields.include?(field_name.to_s)
      end

      def instance_variables_excluding_dirty_tracking_field
        instance_variables.reject{|var| var == :@changed_fields}
      end
    end
  end
end

Version data entries

79 entries across 79 versions & 2 rubygems

Version Path
intercom-3.5.4 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.3 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.2 lib/intercom/traits/dirty_tracking.rb
cogniteev-intercom-2.5.4 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.1 lib/intercom/traits/dirty_tracking.rb
intercom-3.4.0 lib/intercom/traits/dirty_tracking.rb
intercom-3.3.0 lib/intercom/traits/dirty_tracking.rb
intercom-3.2.0 lib/intercom/traits/dirty_tracking.rb
intercom-3.1.0 lib/intercom/traits/dirty_tracking.rb
intercom-3.0.6 lib/intercom/traits/dirty_tracking.rb
intercom-3.0.5 lib/intercom/traits/dirty_tracking.rb
intercom-3.0.4 lib/intercom/traits/dirty_tracking.rb
intercom-3.0.3 lib/intercom/traits/dirty_tracking.rb
intercom-3.0.2 lib/intercom/traits/dirty_tracking.rb
intercom-3.0.0 lib/intercom/traits/dirty_tracking.rb
intercom-3.0.0b1 lib/intercom/traits/dirty_tracking.rb
intercom-2.5.4 lib/intercom/traits/dirty_tracking.rb
intercom-2.4.4 lib/intercom/traits/dirty_tracking.rb
intercom-2.4.3 lib/intercom/traits/dirty_tracking.rb
intercom-2.4.2 lib/intercom/traits/dirty_tracking.rb