module Peregrine::Features::Taggable

Provides methods for adding and removing tags to and from objects. This essentially provides yet another method for identifying and filtering various objects. Intended to be included in classes requiring this functionality.

Public Instance Methods

add_tag(*list)
Alias for: add_tags
add_tags(*list) click to toggle source

Add the given tags to the object. Tags may be any kind of object. Tags identical to existing tags are ignored. Returns an array of all tags this object contains.

# File lib/peregrine/features/taggable.rb, line 16
def add_tags(*list)
  tags.push(*list).uniq!
  tags
end
Also aliased as: add_tag
remove_tag!(*list)
Alias for: remove_tags!
remove_tags!(*list) click to toggle source

Removes the given tags from the object. Returns an array of the removed tags.

# File lib/peregrine/features/taggable.rb, line 24
def remove_tags!(*list)
  removed = []
  tags.reject! { |tag| list.include?(tag) ? removed.push(tag) : false }
  removed
end
Also aliased as: remove_tag!
tags() click to toggle source

Returns the array of tags this object contains. Lazily evaluated.

# File lib/peregrine/features/taggable.rb, line 9
def tags
  @tags ||= []
end