Class: Amrita2::Core::Hook

Inherits:
Object show all
Includes:
ActionView::Helpers::FormHelper
Defined in:
lib/amrita2/rails_bridge.rb,
lib/amrita2/template.rb

Defined Under Namespace

Classes: Renderer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Hook

Returns a new instance of Hook.



1819
1820
1821
# File 'lib/amrita2/template.rb', line 1819

def initialize(&block)
  @hook_proc = block
end

Instance Attribute Details

#cntObject (readonly)

Returns the value of attribute cnt.



1817
1818
1819
# File 'lib/amrita2/template.rb', line 1817

def cnt
  @cnt
end

#element_sObject (readonly)

Returns the value of attribute element_s.



1817
1818
1819
# File 'lib/amrita2/template.rb', line 1817

def element_s
  @element_s
end

#streamObject (readonly)

Returns the value of attribute stream.



1817
1818
1819
# File 'lib/amrita2/template.rb', line 1817

def stream
  @stream
end

Instance Method Details

#call(stream, cnt, element_s, &block) ⇒ Object



1823
1824
1825
1826
1827
1828
1829
# File 'lib/amrita2/template.rb', line 1823

def call(stream, cnt, element_s,&block)
  @stream = stream
  @cnt = cnt
  @element_s = element_s
  @render_me_proc = block
  instance_eval(&@hook_proc)
end

#render_child(name, it) ⇒ Object



1835
1836
1837
# File 'lib/amrita2/template.rb', line 1835

def render_child(name, it)
  stream << @render_me_proc.call(name, it)
end

#render_me_with(it) ⇒ Object



1831
1832
1833
# File 'lib/amrita2/template.rb', line 1831

def render_me_with(it)
  stream << @render_me_proc.call(nil, it)
end