Sha256: 75a4c36d54f76db7abe46841fb7e5f78b03d41d7c55b64bc4fbe692a40937a5d

Contents?: true

Size: 519 Bytes

Versions: 5

Compression:

Stored size: 519 Bytes

Contents

# What about a tag system like annotations, but w/o the associated data?



# Method Tags

class Module
  @@tags = {}
  def tag( taghash )
    # sanitize the taghash
    h = {}
    taghash.each{ |k,v|
      nk = ( Symbol === k ? k : k.to_sym )
      if not self.instance_methods.include?(k.to_s)
        p self.instance_methods
        raise "#{k} is not defined for tagging"
      end
      nv = ( Array === v ? v : [ v ] )
      h[nk] = nv
    }
    # store
    @@tags.update(h)
  end
  def tags
    @@tags
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
facets-1.4.1 forge/more/tag.rb
facets-1.4.2 forge/more/tag.rb
facets-1.4.3 forge/more/tag.rb
facets-1.4.4 forge/more/tag.rb
facets-1.4.5 snip/more/tag.rb