Module: Rabl::Partials

Includes:
Helpers, Sources
Included in:
Builder, Engine
Defined in:
lib/rabl/partials.rb

Instance Method Summary collapse

Methods included from Sources

#fetch_source

Methods included from Helpers

#collection_root_name, #context_scope, #data_name, #data_object, #data_object_attribute, #determine_object_root, #fetch_result_from_cache, #is_collection?, #is_name_value?, #is_object?, #object_root_name, #object_to_engine, #template_cache_configured?, #view_path, #write_result_to_cache

Instance Method Details

#partial_as_engine(file, options = {}, &block) ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rabl/partials.rb', line 6

def partial_as_engine(file, options = {}, &block)
  raise ArgumentError, "Must provide an :object option to render a partial" unless options.has_key?(:object)

  object    = options.delete(:object)
  view_path = options[:view_path] || self.view_path

  source, location = fetch_source(file, :view_path => view_path)

  options = options.merge(:source => source, :source_location => location, :template => file)
  object_to_engine(object, options, &block)
end