Sha256: 3de6414a093eb4562ad708aae5e32657a71c3693116273b2593a817826560758

Contents?: true

Size: 712 Bytes

Versions: 8

Compression:

Stored size: 712 Bytes

Contents

# frozen_string_literal: true

# For Rails <= 4.1
module Gutentag::ActiveRecord::InstanceMethods
  # The reason we overwrite the stored value is because new tags may be added to
  # the instance directly (e.g. article.tags << tag), which invokes the save
  # callbacks, but the old tag_names value is stored but not updated.
  def reset_tag_names
    @tag_names = nil
  end

  def tag_names
    @tag_names ||= tags.pluck(:name)
  end

  def tag_names=(names)
    names = Gutentag::TagNames.call(names)

    Gutentag.dirtier.call self, names if Gutentag.dirtier.present?

    @tag_names = names
  end

  private

  def persist_tags
    Gutentag::Persistence.new(Gutentag::ChangeState.new(self)).persist
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gutentag-2.6.2 lib/gutentag/active_record/instance_methods_3_2.rb
gutentag-2.6.1 lib/gutentag/active_record/instance_methods_3_2.rb
gutentag-2.6.0 lib/gutentag/active_record/instance_methods_3_2.rb
gutentag-2.5.4 lib/gutentag/active_record/instance_methods_3_2.rb
gutentag-2.5.3 lib/gutentag/active_record/instance_methods_3_2.rb
gutentag-2.5.2 lib/gutentag/active_record/instance_methods_3_2.rb
gutentag-2.5.1 lib/gutentag/active_record/instance_methods_3_2.rb
gutentag-2.5.0 lib/gutentag/active_record/instance_methods_3_2.rb