Sha256: 510279311581cffd3de8c175bbed8418701797694de6dee2f6d2c58ca08cd385

Contents?: true

Size: 605 Bytes

Versions: 4

Compression:

Stored size: 605 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
    end
  end

  def tag_names
    @tag_names ||= Gutentag::TagNames.new self
  end

  def tag_names=(names)
    if names.is_a?(Gutentag::TagNames)
      @tag_names = names
    else
      @tag_names = Gutentag::TagNames.new_with_names self, names
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gutentag-0.2.2 lib/gutentag/active_record.rb
gutentag-0.2.1 lib/gutentag/active_record.rb
gutentag-0.2.0 lib/gutentag/active_record.rb
gutentag-0.1.0 lib/gutentag/active_record.rb