Sha256: caddb550f46bacc3833c74a1ca01c230db2a139107324d72878676be3e2131a2

Contents?: true

Size: 609 Bytes

Versions: 19

Compression:

Stored size: 609 Bytes

Contents

# frozen_string_literal: true

class Gutentag::ChangeState
  attr_reader :taggable
  attr_writer :normaliser

  def initialize(taggable)
    @taggable = taggable
    @existing = normalised taggable.tags.collect(&:name)
    @changes  = normalised taggable.tag_names
  end

  def added
    @added ||= changes - existing
  end

  def removed
    @removed ||= existing - changes
  end

  private

  attr_reader :existing, :changes

  def normalised(names)
    names.collect { |name| normaliser.call(name) }.uniq
  end

  def normaliser
    @normaliser ||= proc { |name| Gutentag.normaliser.call(name) }
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
gutentag-2.6.2 lib/gutentag/change_state.rb
gutentag-2.6.1 lib/gutentag/change_state.rb
gutentag-2.6.0 lib/gutentag/change_state.rb
gutentag-2.5.4 lib/gutentag/change_state.rb
gutentag-2.5.3 lib/gutentag/change_state.rb
gutentag-2.5.2 lib/gutentag/change_state.rb
gutentag-2.5.1 lib/gutentag/change_state.rb
gutentag-2.5.0 lib/gutentag/change_state.rb
gutentag-2.4.1 lib/gutentag/change_state.rb
gutentag-2.4.0 lib/gutentag/change_state.rb
gutentag-2.3.2 lib/gutentag/change_state.rb
gutentag-2.3.1 lib/gutentag/change_state.rb
gutentag-2.3.0 lib/gutentag/change_state.rb
gutentag-2.2.1 lib/gutentag/change_state.rb
gutentag-2.2.0 lib/gutentag/change_state.rb
gutentag-2.1.0 lib/gutentag/change_state.rb
gutentag-2.0.0 lib/gutentag/change_state.rb
gutentag-1.1.0 lib/gutentag/change_state.rb
gutentag-1.0.0 lib/gutentag/change_state.rb