require 'traits' # # getters delegate to setters iff called with arguments # class AbstractWidget class_trait 'color' => 'pinky-green' class_trait 'size' => 42 class_trait 'shape' => 'square' trait 'color' trait 'size' trait 'shape' def initialize color self.class.color size self.class.size shape self.class.shape end def inspect "color <#{ color }> size <#{ size }> shape <#{ shape }>" end end class BlueWidget < AbstractWidget color 'blue' size 420 end p BlueWidget::new