Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/on_irc/config_accessor.rb,
lib/on_irc/dsl_accessor.rb
Overview
config accessors
Instance Method Summary collapse
- #bool_dsl_accessor(*symbols) ⇒ Object
- #config_accessor(*symbols) ⇒ Object
-
#dsl_accessor(*symbols) ⇒ Object
taken from www.artima.com/rubycs/articles/ruby_as_dsl3.html used for the IRC.new config DSL.
Instance Method Details
#bool_dsl_accessor(*symbols) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/on_irc/dsl_accessor.rb', line 18 def bool_dsl_accessor(*symbols) symbols.each do |sym| class_eval %{ def #{sym}(val = true) @#{sym} = !!val end def #{sym}? !!@#{sym} end } end end |
#config_accessor(*symbols) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/on_irc/config_accessor.rb', line 3 def config_accessor(*symbols) symbols.each do |sym| class_eval %{ def #{sym} config.#{sym} end def #{sym}=(val) config.#{sym} = val end } end end |
#dsl_accessor(*symbols) ⇒ Object
taken from www.artima.com/rubycs/articles/ruby_as_dsl3.html used for the IRC.new config DSL
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/on_irc/dsl_accessor.rb', line 4 def dsl_accessor(*symbols) symbols.each do |sym| class_eval %{ def #{sym}(*val) if val.empty? @#{sym} else @#{sym} = val.size == 1 ? val[0] : val end end } end end |