Module: Ruby2html::ComponentHelper

Defined in:
lib/gem/ruby2html/component_helper.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, **options, &block) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/gem/ruby2html/component_helper.rb', line 15

def method_missing(method, *args, **options, &block)
  if __ruby2html_renderer__.respond_to?(method)
    __ruby2html_renderer__.send(method, *args, **options, &block)
  else
    super
  end
end

Instance Method Details

#__ruby2html_renderer__Object



23
24
25
# File 'lib/gem/ruby2html/component_helper.rb', line 23

def __ruby2html_renderer__
  Thread.current[:__ruby2html_renderer__]
end

#html(&block) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/gem/ruby2html/component_helper.rb', line 5

def html(&block)
  previous_renderer = __ruby2html_renderer__
  Ruby2html::Render.new(self, &block).yield_self do |component_renderer|
    Thread.current[:__ruby2html_renderer__] = component_renderer
    component_renderer.render.html_safe
  end
ensure
  Thread.current[:__ruby2html_renderer__] = previous_renderer
end