Sha256: 25ac33f621d805569037851fa47caf1ba698b2e399e2c523e31605972fd2be72

Contents?: true

Size: 523 Bytes

Versions: 4

Compression:

Stored size: 523 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

4 entries across 4 versions & 1 rubygems

Version Path
facets-1.8.0 work/more/tag.rb
facets-1.8.20 work/more/tag.rb
facets-1.8.49 work/more/tag.rb
facets-1.8.8 work/more/tag.rb