Method: Innate::Node#alias_view

Defined in:
lib/innate/node.rb

#alias_view(to, from, node = nil) ⇒ Object

Aliasing one view from another. The aliases are inherited, and the optional third node parameter indicates the Node to take the view from.

The argument order is identical with alias and alias_method, which quite honestly confuses me, but at least we stay consistent.

Note that the parameters have been simplified in comparision with Ramaze::Controller::template where the second parameter may be a Controller or the name of the template. We take that now as an optional third parameter.

Examples:

class Foo
  include Innate::Node

  # Use the 'foo' view when calling 'bar'
  alias_view 'bar', 'foo'

  # Use the 'foo' view from FooBar node when calling 'bar'
  alias_view 'bar', 'foo', FooBar
end

Parameters:

  • to (#to_s)

    view that should be replaced

  • from (#to_s)

    view to use or Node.

  • node (#nil?, Node) (defaults to: nil)

    optionally obtain view from this Node

See Also:

  • Node::find_aliased_view

Author:

  • manveru



615
616
617
618
# File 'lib/innate/node.rb', line 615

def alias_view(to, from, node = nil)
  trait[:alias_view] || trait(:alias_view => {})
  trait[:alias_view][to.to_s] = node ? [from.to_s, node] : from.to_s
end