Module: DelegateIt
- Defined in:
- lib/delegate_it.rb,
lib/delegate_it/main.rb,
lib/delegate_it/version.rb
Constant Summary collapse
- VERSION =
"1.1.1"
Instance Method Summary collapse
Instance Method Details
#delegate(*methods, options) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/delegate_it/main.rb', line 3 def delegate *methods, methods.each do |method| method_name = if [:prefix] && [:prefix].is_a?(Symbol) "#{[:prefix]}_#{method}" elsif [:prefix] "#{[:to]}_#{method}" else method end define_method method_name do |*args| receiver = self.send([:to]) if [:allow_nil] && !receiver nil else receiver.send(method, *args) end end end end |