Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/cnab240/ext/attribute_accessors.rb
Overview
Taken from Rails 2.1
Instance Method Summary collapse
- #mod_attr_accessor(*syms) ⇒ Object
- #mod_attr_reader(*syms) ⇒ Object
- #mod_attr_writer(*syms) ⇒ Object
Instance Method Details
#mod_attr_accessor(*syms) ⇒ Object
43 44 45 46 |
# File 'lib/cnab240/ext/attribute_accessors.rb', line 43 def mod_attr_accessor(*syms) mod_attr_reader(*syms) mod_attr_writer(*syms) end |
#mod_attr_reader(*syms) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/cnab240/ext/attribute_accessors.rb', line 3 def mod_attr_reader(*syms) syms.each do |sym| next if sym.is_a?(Hash) class_eval(<<-EOS, __FILE__, __LINE__) unless defined? @@#{sym} @@#{sym} = nil end def self.#{sym} @@#{sym} end def #{sym} @@#{sym} end EOS end end |
#mod_attr_writer(*syms) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cnab240/ext/attribute_accessors.rb', line 22 def mod_attr_writer(*syms) = syms syms.each do |sym| class_eval(<<-EOS, __FILE__, __LINE__) unless defined? @@#{sym} @@#{sym} = nil end def self.#{sym}=(obj) @@#{sym} = obj end #{" def #{sym}=(obj) @@#{sym} = obj end " } EOS end end |