Module: TraitInit::InstaceMethods

Defined in:
lib/traits.rb,
lib/traits-0.10.0.rb

Overview

–{{{

Instance Method Summary collapse

Instance Method Details

#trait_init(*argv) ⇒ Object Also known as: traitinit



882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
# File 'lib/traits.rb', line 882

def trait_init *argv
#--{{{
  args, opts = argv.partition{|arg| not Hash === arg}
  args.flatten!
  opts = opts.inject({}){|h,h2| h.update h2}
  msgs = self.class.r_traits
  args.each{|arg| send msgs.shift, arg}
  opts.each do |k,v| 
    k = "#{ k }"
    if respond_to? k
      send k, v
    else
      raise ArgumentError, "invalid trait -- #{ self.class }##{ k }"
    end
  end
#--}}}
end