module ClassyAdornments def self.included(base) base.extend(self) end def adorn(name,opts = {}) adorn_with name if opts.empty? adorn_with_array name if opts[:array] end private def adorn_with(name) define_method(name) do |*args| var = '@' + name.to_s if args.first return instance_variable_set(var,args.first) else return instance_variable_get(var) end end alias_method "#{name}=", name end def adorn_with_array(name) define_method(name) do |*args| var = '@' + name.to_s instance_variable_set(var,Array.new) if instance_variable_get(var).nil? return case args.first when nil instance_variable_get(var) when Array instance_variable_get(var).concat args.first else instance_variable_get(var).concat args end end end end