module Selectable::Object

Helper methods for objects with a @tags instance var

e.g.

class Something
  include Selectable::Object
end

Attributes

tags[RW]

Public Instance Methods

add_tag(tags)
Alias for: add_tags
add_tag_quick(tags)
Alias for: add_tags_quick
add_tags(tags) click to toggle source
# File lib/selectable/object.rb, line 14
def add_tags(tags)
  init_tags!
  @tags.merge! tags
end
Also aliased as: add_tag
add_tags_quick(tags) click to toggle source
# File lib/selectable/object.rb, line 19
def add_tags_quick(tags)
  @tags.merge! tags
end
Also aliased as: add_tag_quick
init_tags!() click to toggle source
# File lib/selectable/object.rb, line 37
def init_tags!
  @tags ||= Selectable::Tags.new
end
remove_tag(*tags)
Alias for: remove_tags
remove_tags(*tags) click to toggle source
# File lib/selectable/object.rb, line 23
def remove_tags(*tags)
  raise TagsNotInitialized if @tags.nil?
  tags.flatten!
  @tags.delete_if { |n,v| tags.member?(n) }
end
Also aliased as: remove_tag
tag_values(*tags) click to toggle source
# File lib/selectable/object.rb, line 29
def tag_values(*tags)
  raise TagsNotInitialized if @tags.nil?
  tags.flatten!
  ret = @tags.collect { |n,v| 
    v if tags.empty? || tags.member?(n) 
  }.compact
  ret
end