Module: PierConsoleDetective::ModAttrAccessor
- Included in:
- PierConsoleDetective
- Defined in:
- lib/pier_console_detective/mod_attr_accessor.rb
Instance Method Summary collapse
Instance Method Details
#mod_attr_accessor(attr_name, default_value) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pier_console_detective/mod_attr_accessor.rb', line 6 def mod_attr_accessor(attr_name, default_value) class_eval(" @@\#{attr_name} = nil unless defined? @@\#{attr_name}\n\n def self.\#{attr_name}\n @@\#{attr_name}\n end\n\n def self.\#{attr_name}=(obj)\n @@\#{attr_name} = obj\n end\n EOS\n\n send(\"\#{attr_name}=\", default_value) unless default_value.nil?\nend\n", __FILE__, __LINE__ + 1) |