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.26 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.25 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.24 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.23 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.22 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.21 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.20 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.19 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.17 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.16 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.15 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.14 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.12 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.11 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.10 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.9 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.8 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.7 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.6 lib/intercom/traits/dirty_tracking.rb
intercom-3.5.5 lib/intercom/traits/dirty_tracking.rb