Module: Alchemy::Taggable

Included in:
Attachment, Element, Page, Picture
Defined in:
lib/alchemy/taggable.rb

Overview

ActsAsTaggableOn to Gutentag interface compatibility module Include this module to add tagging support to your model.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
# File 'lib/alchemy/taggable.rb', line 7

def self.included(base)
  Gutentag::ActiveRecord.call base
  base.extend ClassMethods
  base.send(:alias_method, :tag_list, :tag_names)
end

Instance Method Details

#tag_list=(tags) ⇒ Object

Set a list of tags Pass a String with comma separated tag names or an Array of tag names



16
17
18
19
20
21
22
23
# File 'lib/alchemy/taggable.rb', line 16

def tag_list=(tags)
  case tags
  when String
    self.tag_names = tags.split(/,\s*/)
  when Array
    self.tag_names = tags
  end
end