Ara,

Any plans to gemify traits?

Cheers ...

"Ara.T.Howard" <Ara.T.Howard / noaa.gov> wrote in message
>
> traits let's you do this easily:
>
>    harp:~ > cat a.rb
>    require 'traits'
>
>    class People
>      trait 'cat' => true
>    end
>    p People::new.cat
>
>    # or
>
>    module KeywordClass
>      def self::new *a, &b
>        klass = Class::new { a.each{|t| trait t} }
>        klass.module_eval &b if b
>        klass
>      end
>    end
>    People2 = KeywordClass::new 'hat', 'cat' => true
>    p People2::new.cat
>    p People2::new.hat
>
>    People3 = KeywordClass::new(%w(cat in the hat)){ trait 'striped' =>
true }
>    person = People3::new
>    People3.reader_traits.each{|t| p t => person.send(t)}
>
>
>    harp:~ > ruby a.rb
>    true
>    true
>    nil
>    {"cat"=>nil}
>    {"in"=>nil}
>    {"hat"=>nil}
>    {"the"=>nil}
>    {"striped"=>true}
>
> hth.  traits also inherit their default values up the general inheritence
> hierarchy - even for class traits.
>
> -a
> -- 
>
============================================================================
===
> | email :: ara [dot] t [dot] howard [at] noaa [dot] gov
> | phone :: 303.497.6469
> | Your life dwells amoung the causes of death
> | Like a lamp standing in a strong breeze.  --Nagarjuna
>
============================================================================
===
>
>
>