Class: RablRails::Renderer::Context
- Inherits:
-
Object
- Object
- RablRails::Renderer::Context
- Defined in:
- lib/rabl-rails/renderer.rb
Overview
Context class to emulate normal Rails view context
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
Instance Method Summary collapse
- #assigns ⇒ Object
-
#initialize(path, options) ⇒ Context
constructor
A new instance of Context.
- #lookup_context ⇒ Object
- #params ⇒ Object
Constructor Details
#initialize(path, options) ⇒ Context
Returns a new instance of Context.
39 40 41 42 43 44 45 46 |
# File 'lib/rabl-rails/renderer.rb', line 39 def initialize(path, ) @virtual_path = path @format = .delete(:format) || 'json' @_assigns = {} @options = [:locals].each { |k, v| @_assigns[k.to_s] = v } if [:locals] end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
37 38 39 |
# File 'lib/rabl-rails/renderer.rb', line 37 def format @format end |
Instance Method Details
#assigns ⇒ Object
48 49 50 |
# File 'lib/rabl-rails/renderer.rb', line 48 def assigns @_assigns end |
#lookup_context ⇒ Object
56 57 58 |
# File 'lib/rabl-rails/renderer.rb', line 56 def lookup_context @lookup_context ||= LookupContext.new(@options[:view_path], format) end |
#params ⇒ Object
52 53 54 |
# File 'lib/rabl-rails/renderer.rb', line 52 def params { format: format } end |