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


5
6
7
8
9
# File 'lib/alchemy/taggable.rb', line 5

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


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

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