Module: AdminWidgets::Delegation

Included in:
BaseWidget, ListWidget::Header
Defined in:
lib/admin_widgets/delegation.rb

Instance Method Summary collapse

Instance Method Details

#delegate(*methods) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/admin_widgets/delegation.rb', line 3

def delegate(*methods)
  options = methods.last
  keys = methods[0..-2]

  if options.is_a?(Hash) and options[:hash]
    keys.each do |key|
      define_method key do
        hash = self.send(options[:to])
        hash.send(:[], key)
      end
    end
  else
    super *methods
  end

end