Class: AdminWidgets::BaseWidget

Inherits:
Erector::Widget
  • Object
show all
Extended by:
Delegation, Memoization
Defined in:
lib/admin_widgets/base_widget.rb

Instance Method Summary collapse

Methods included from Memoization

memoize

Methods included from Delegation

delegate

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



24
25
26
# File 'lib/admin_widgets/base_widget.rb', line 24

def method_missing(method_name, *args, &block)
  rawtext helper.send(method_name, *args, &block)
end

Instance Method Details

#capture(&block) ⇒ Object

Outputs to a new buffer



7
8
9
10
11
12
13
14
# File 'lib/admin_widgets/base_widget.rb', line 7

def capture(&block)
  original, @_output = output, Erector::Output.new
  instance_eval &block
  original.widgets.concat(output.widgets)
  output.to_s
ensure
  @_output = original
end

#content_blockObject



28
29
30
# File 'lib/admin_widgets/base_widget.rb', line 28

def content_block
  instance_eval &@block if @block
end

#helperObject



20
21
22
# File 'lib/admin_widgets/base_widget.rb', line 20

def helper
  @controller.view_context
end

#rootObject



16
17
18
# File 'lib/admin_widgets/base_widget.rb', line 16

def root
  parent and parent.root or self
end