Sha256: 6b3461e89d1e209101b875a186ff1314bda0cda5b15b7530e76ff678052c8e46

Contents?: true

Size: 584 Bytes

Versions: 4

Compression:

Stored size: 584 Bytes

Contents

# frozen_string_literal: true

class Gutentag::ActiveRecord
  def self.call(model)
    model.has_many :taggings,
      :class_name => "Gutentag::Tagging",
      :as         => :taggable,
      :dependent  => :destroy
    model.has_many :tags,
      :class_name => "Gutentag::Tag",
      :through    => :taggings

    model.after_save :persist_tags

    model.send :extend,  Gutentag::ActiveRecord::ClassMethods
    model.send :include, Gutentag::ActiveRecord::InstanceMethods
  end
end

require "gutentag/active_record/class_methods"
require "gutentag/active_record/instance_methods"

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gutentag-2.1.0 lib/gutentag/active_record.rb
gutentag-2.0.0 lib/gutentag/active_record.rb
gutentag-1.1.0 lib/gutentag/active_record.rb
gutentag-1.0.0 lib/gutentag/active_record.rb