lib/glue/attribute.rb in glue-0.20.0 vs lib/glue/attribute.rb in glue-0.21.0

- old
+ new

@@ -15,19 +15,19 @@ # @@-attributes. #++ class Module # :nodoc: - # A macro that creates a reader method for class/module - # attributes. - + # A macro that creates a reader method for class/module + # attributes. + def mattr_reader(*params) - default = if params.last.is_a?(Symbol) then nil else params.pop end - + default = if params.last.is_a?(Symbol) then nil else params.pop end + for sym in params - module_eval <<-"end_eval", __FILE__, __LINE__ - + module_eval <<-"end_eval", __FILE__, __LINE__ + if not defined?(@@#{sym.id2name}) @@#{sym.id2name} = #{default.inspect} end def self.#{sym.id2name} @@ -37,18 +37,18 @@ end_eval end end alias_method :cattr_reader, :mattr_reader - # A macro that creates a writer method for class/module - # attributes. + # A macro that creates a writer method for class/module + # attributes. def mattr_writer(*params) - default = if params.last.is_a?(Symbol) then nil else params.pop end - + default = if params.last.is_a?(Symbol) then nil else params.pop end + for sym in params - module_eval <<-"end_eval", __FILE__, __LINE__ + module_eval <<-"end_eval", __FILE__, __LINE__ if not defined?(@@#{sym.id2name}) @@#{sym.id2name} = #{default.inspect.inspect} end @@ -63,17 +63,17 @@ end_eval end end alias_method :cattr_writer, :cattr_writer - # A macro that creates a reader and a writer method for - # class/module attributes. + # A macro that creates a reader and a writer method for + # class/module attributes. def mattr_accessor(*syms) mattr_reader(*syms) mattr_writer(*syms) end alias_method :cattr_accessor, :mattr_accessor - + end # * George Moschovitis <gm@navel.gr>