Class | Prototype |
In: |
lib/more/facets/prototype.rb
|
Parent: | Object |
New prototype object.
# File lib/more/facets/prototype.rb, line 16 def initialize(&block) @traits = [] instance_eval(&block) h = {} iv = instance_variables iv.each { |k| h[k[1..-1].to_sym] = instance_eval{ instance_variable_get(k) } } meta.class_eval do h.each do |k,v| case v when Proc #define_method(k){ |*args| v[*args] } attr_reader k else attr_accessor k end end end end
# File lib/more/facets/prototype.rb, line 58 def method_missing(s, *a, &b) if trait = traits.find{ |t| t.method_defined?(s) } trait.send(s,*a,&b) else super end end