Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/sparrow/utils.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#mattr_accessor(*syms) ⇒ Object
83 84 85 86 |
# File 'lib/sparrow/utils.rb', line 83 def mattr_accessor(*syms) mattr_reader(*syms) mattr_writer(*syms) end |
#mattr_reader(*syms) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/sparrow/utils.rb', line 46 def mattr_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 |
#mattr_writer(*syms) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/sparrow/utils.rb', line 65 def mattr_writer(*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 |