Sha256: a4271534473d8d90e88e919e239c122e38ea3af7e00ee194bb7660a335c92f30

Contents?: true

Size: 641 Bytes

Versions: 1

Compression:

Stored size: 641 Bytes

Contents

require 'active_support/concern'

module Gutentag::ActiveRecord
  extend ActiveSupport::Concern

  module ClassMethods
    def has_many_tags
      has_many :taggings, :class_name => 'Gutentag::Tagging', :as => :taggable,
        :dependent => :destroy
      has_many :tags,     :class_name => 'Gutentag::Tag',
        :through => :taggings

      after_save { |instance| Gutentag::Persistence.new(instance).persist  }
    end
  end

  def reset_tag_names
    @tag_names = nil
  end

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

  def tag_names=(names)
    Gutentag::Dirty.call self, names

    @tag_names = names
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gutentag-0.5.1 lib/gutentag/active_record.rb