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-2.4.1 lib/intercom/traits/dirty_tracking.rb
intercom-2.4.0 lib/intercom/traits/dirty_tracking.rb
intercom-2.3.0 lib/intercom/traits/dirty_tracking.rb
intercom-2.2.4 lib/intercom/traits/dirty_tracking.rb
intercom-2.2.3 lib/intercom/traits/dirty_tracking.rb
intercom-2.2.2 lib/intercom/traits/dirty_tracking.rb
intercom-2.2.1 lib/intercom/traits/dirty_tracking.rb
intercom-2.2.0 lib/intercom/traits/dirty_tracking.rb
intercom-2.1.6 lib/intercom/traits/dirty_tracking.rb
intercom-2.1.5 lib/intercom/traits/dirty_tracking.rb
intercom-2.1.4 lib/intercom/traits/dirty_tracking.rb
intercom-2.1.3 lib/intercom/traits/dirty_tracking.rb
intercom-2.1.2 lib/intercom/traits/dirty_tracking.rb
intercom-2.1.1 lib/intercom/traits/dirty_tracking.rb
intercom-2.1.0 lib/intercom/traits/dirty_tracking.rb
intercom-2.0.3 lib/intercom/traits/dirty_tracking.rb
intercom-2.0.2 lib/intercom/traits/dirty_tracking.rb
intercom-2.0.1 lib/intercom/traits/dirty_tracking.rb
intercom-2.0.0 lib/intercom/traits/dirty_tracking.rb