Sha256: 9ed01c83433fb212006b042c7445f559e3f07a4fc5e58b5cba14209a62a5bd6a
Contents?: true
Size: 647 Bytes
Versions: 4
Compression:
Stored size: 647 Bytes
Contents
# frozen_string_literal: true require "forwardable" class Gutentag::Persistence extend Forwardable attr_writer :tagger def initialize(change_state) @change_state = change_state end def persist remove_old add_new taggable.reset_tag_names end private attr_reader :change_state def_delegators :change_state, :taggable, :added, :removed def add_new added.each do |name| taggable.tags << tagger.find_or_create(name) end end def remove_old removed.each do |name| taggable.tags.delete tagger.find_by_name(name) end end def tagger @tagger ||= Gutentag::Tag end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
gutentag-2.1.0 | lib/gutentag/persistence.rb |
gutentag-2.0.0 | lib/gutentag/persistence.rb |
gutentag-1.1.0 | lib/gutentag/persistence.rb |
gutentag-1.0.0 | lib/gutentag/persistence.rb |