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-4.0.1 lib/intercom/traits/dirty_tracking.rb
intercom-4.0.0 lib/intercom/traits/dirty_tracking.rb
intercom-3.9.5 lib/intercom/traits/dirty_tracking.rb
intercom-3.9.4 lib/intercom/traits/dirty_tracking.rb
intercom-3.9.3 lib/intercom/traits/dirty_tracking.rb
intercom-3.9.2 lib/intercom/traits/dirty_tracking.rb
intercom-3.9.0 lib/intercom/traits/dirty_tracking.rb
intercom-3.8.1 lib/intercom/traits/dirty_tracking.rb
intercom-3.8.0 lib/intercom/traits/dirty_tracking.rb
intercom-3.7.7 lib/intercom/traits/dirty_tracking.rb
intercom-3.7.6 lib/intercom/traits/dirty_tracking.rb
intercom-3.7.5 lib/intercom/traits/dirty_tracking.rb
intercom-3.7.4 lib/intercom/traits/dirty_tracking.rb
intercom-3.7.3 lib/intercom/traits/dirty_tracking.rb
intercom-3.7.2 lib/intercom/traits/dirty_tracking.rb
intercom-3.7.1 lib/intercom/traits/dirty_tracking.rb
intercom-3.7.0 lib/intercom/traits/dirty_tracking.rb
intercom-3.6.2 lib/intercom/traits/dirty_tracking.rb
intercom-3.6.1 lib/intercom/traits/dirty_tracking.rb
intercom-3.6.0 lib/intercom/traits/dirty_tracking.rb