Sha256: abaeef47be3b78d9be75088822eeba9e1e802ea15701b8f7b405843a3f8864a2

Contents?: true

Size: 460 Bytes

Versions: 5

Compression:

Stored size: 460 Bytes

Contents

class Gutentag::Dirty
  def self.call(instance, tag_names)
    new(instance, tag_names).call
  end

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

  def call
    instance.changed_attributes[:tag_names] = existing if changes.present?
  end

  private

  attr_reader :instance, :tag_names

  def changes
    (existing + tag_names).uniq - (existing & tag_names)
  end

  def existing
    instance.tag_names
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gutentag-0.9.0 lib/gutentag/dirty.rb
gutentag-0.8.0 lib/gutentag/dirty.rb
gutentag-0.7.0 lib/gutentag/dirty.rb
gutentag-0.6.0 lib/gutentag/dirty.rb
gutentag-0.5.1 lib/gutentag/dirty.rb