Module: Intercom::Traits::DirtyTracking

Included in:
ApiResource
Defined in:
lib/intercom/traits/dirty_tracking.rb

Instance Method Summary collapse

Instance Method Details

#field_changed?(field_name) ⇒ Boolean


23
24
25
26
# File 'lib/intercom/traits/dirty_tracking.rb', line 23

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

#instance_variables_excluding_dirty_tracking_fieldObject


28
29
30
# File 'lib/intercom/traits/dirty_tracking.rb', line 28

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

#mark_field_as_changed!(field_name) ⇒ Object


18
19
20
21
# File 'lib/intercom/traits/dirty_tracking.rb', line 18

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

#mark_fields_as_changed!(field_names) ⇒ Object


11
12
13
14
15
16
# File 'lib/intercom/traits/dirty_tracking.rb', line 11

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

#reset_changed_fields!Object


7
8
9
# File 'lib/intercom/traits/dirty_tracking.rb', line 7

def reset_changed_fields!
  @changed_fields = Set.new
end