Sha256: e1e62847cf2c5eed4adae743d8bdb162dc647ae505bbe918292e45c172241dc1

Contents?: true

Size: 716 Bytes

Versions: 10

Compression:

Stored size: 716 Bytes

Contents

module Tagalong
  module Taggable
    def self.included(base)
      base.extend ClassMethods
    end

    module ClassMethods
      def tagalong_taggable
        class_eval do
          has_many :tagalong_taggings, :class_name => 'Tagalong::TagalongTagging', :as => :taggable
          has_many :tagalong_tags, :class_name => 'Tagalong::TagalongTag', :through => :tagalong_taggings
          include Tagalong::Taggable::InstanceMethods
        end
      end
    end

    module InstanceMethods
      def tagged_with?(name)
        return self.tagalong_tags.map { |r| r.name }.include?(name)
      end

      def tags
        return self.tagalong_tags.order("name ASC").map { |r| r.name }
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tagalong-0.1.3 lib/tagalong/taggable.rb
tagalong-0.1.2 lib/tagalong/taggable.rb
tagalong-0.1.1 lib/tagalong/taggable.rb
tagalong-0.1.0 lib/tagalong/taggable.rb
tagalong-0.0.9 lib/tagalong/taggable.rb
tagalong-0.0.8 lib/tagalong/taggable.rb
tagalong-0.0.7 lib/tagalong/taggable.rb
tagalong-0.0.6 lib/tagalong/taggable.rb
tagalong-0.0.5 lib/tagalong/taggable.rb
tagalong-0.0.4 lib/tagalong/taggable.rb