Class: Gutentag::Dirty

Inherits:
Object
  • Object
show all
Defined in:
lib/gutentag/dirty.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance, tag_names) ⇒ Dirty

Returns a new instance of Dirty.



8
9
10
11
# File 'lib/gutentag/dirty.rb', line 8

def initialize(instance, tag_names)
  @instance  = instance
  @tag_names = tag_names
end

Class Method Details

.call(instance, tag_names) ⇒ Object



4
5
6
# File 'lib/gutentag/dirty.rb', line 4

def self.call(instance, tag_names)
  new(instance, tag_names).call
end

Instance Method Details

#callObject



13
14
15
16
17
18
# File 'lib/gutentag/dirty.rb', line 13

def call
  return unless changes.present?

  instance.tag_names_will_change!
  instance.changed_attributes[:tag_names] = existing
end