Sha256: 1902182e2daf1ca329f0697ff021b0db22bf021177e3d308ae49b22d033d4405

Contents?: true

Size: 877 Bytes

Versions: 8

Compression:

Stored size: 877 Bytes

Contents

# Thanks to https://github.com/mbleigh/acts-as-taggable-on
module Odania
	module Taggable
		autoload :Core, 'odania/taggable/core'
		autoload :TagModule, 'odania/taggable/tag_module'
		autoload :TagCount, 'odania/taggable/tag_count'

		def taggable?
			false
		end

		def acts_as_taggable
			taggable_on(:tags)
		end

		private

		def taggable_on(*tag_types)
			if taggable?
				self.tag_types = (self.tag_types + tag_types).uniq
			else
				tag_types = tag_types.to_a.flatten.compact.map(&:to_sym)
				class_attribute :tag_types
				self.tag_types = tag_types

				class_eval do
					has_many :tag_xrefs, :as => :ref, :dependent => :destroy, :class_name => 'Odania::TagXref'
					has_many :tags, :through => :tag_xrefs, :source => :tag, :class_name => 'Odania::Tag'

					def self.taggable?
						true
					end
				end
			end

			include Odania::Taggable::Core
		end
	end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
odania_core-0.0.8 lib/odania/taggable.rb
odania_core-0.0.7 lib/odania/taggable.rb
odania_core-0.0.6 lib/odania/taggable.rb
odania_core-0.0.5 lib/odania/taggable.rb
odania_core-0.0.4 lib/odania/taggable.rb
odania_core-0.0.3 lib/odania/taggable.rb
odania_core-0.0.2 lib/odania/taggable.rb
odania_core-0.0.1 lib/odania/taggable.rb