Sha256: af23e30ac964c00c92e7af95a4357546b4451542846dee0d7779773a6dd937c6
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
module Anise require 'anise/annotation.rb' # = Annotator # # Annotator allows for the creation of dynamic method # annotations which attach to the next method defined. # # require 'anise/annotator' # # class X # include Anise::Annotator # # annotator :doc # # doc "See what I mean?" # # def see # puts "Yes, I see!" # end # end # # X.ann(:see, :doc) #=> "See what I mean?" # #-- # TODO: Thread safety of @pending_annotations. #++ module Annotator def self.append_features(base) #if base == Object # Module.send(:include, self) # FIXME: Module ? #else base.extend Annotation #unless base.is_a?(Annotation) base.extend self #end end def annotator(name) (class << self; self; end).module_eval do define_method(name) do |*args| @pending_annotations ||= [] @pending_annotations << [name, args] end end end def method_added(sym) @pending_annotations ||= [] @pending_annotations.each do |name, args| ann sym, name => args end @pending_annotations = [] super if defined?(super) end end end # Copyright (c) 2005, 2008 TigerOps
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
anise-0.2.1 | lib/anise/annotator.rb |