Module: HelloBlock::Utils

Included in:
Configuration
Defined in:
lib/helloblock/utils.rb

Instance Method Summary collapse

Instance Method Details

#mattr_accessor(*syms) ⇒ Object



2
3
4
5
6
7
# File 'lib/helloblock/utils.rb', line 2

def mattr_accessor(*syms)
  syms.each do |sym|
    mattr_reader(sym)
    mattr_writer(sym)
  end
end

#mattr_reader(sym) ⇒ Object



9
10
11
# File 'lib/helloblock/utils.rb', line 9

def mattr_reader(sym)
  module_eval("def #{sym}; @#{sym}; end")
end

#mattr_writer(sym) ⇒ Object



13
14
15
16
# File 'lib/helloblock/utils.rb', line 13

def mattr_writer(sym)
  module_eval("def #{sym}=(obj); @#{sym} = obj; end")
  module_eval("@#{sym} = nil unless defined? @#{sym}")
end