Class: SproutCore::ViewHelperSupport::HelperState

Inherits:
Object
  • Object
show all
Defined in:
lib/sproutcore/deprecated/view_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(helper_name, opts = {}, &block) ⇒ HelperState

Returns a new instance of HelperState.



510
511
512
513
514
515
516
517
# File 'lib/sproutcore/deprecated/view_helper.rb', line 510

def initialize(helper_name, opts={}, &block)
  @name = helper_name
  @prepare_block = block
  unless helper_name == :view
    @parent_helper = SproutCore::ViewHelperSupport.find_helper(opts[:wraps] || opts[:extends] || :view)
  end
  @extends = opts[:wraps].nil?
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



506
507
508
# File 'lib/sproutcore/deprecated/view_helper.rb', line 506

def name
  @name
end

#parent_helperObject (readonly)

Returns the value of attribute parent_helper.



507
508
509
# File 'lib/sproutcore/deprecated/view_helper.rb', line 507

def parent_helper
  @parent_helper
end

#prepare_blockObject (readonly)

Returns the value of attribute prepare_block.



508
509
510
# File 'lib/sproutcore/deprecated/view_helper.rb', line 508

def prepare_block
  @prepare_block
end

Instance Method Details

#prepare_context(render_context) ⇒ Object



519
520
521
522
523
524
525
526
527
528
529
# File 'lib/sproutcore/deprecated/view_helper.rb', line 519

def prepare_context(render_context)
  # automatically call parent helper if extends was used.
  if parent_helper && @extends
    parent_helper.prepare_context(render_context)
  else
    render_context.current_helper = self
  end

  render_context.instance_eval &prepare_block
  render_context.current_helper = nil
end