Class: RablRails::Renderer::ViewContext
- Inherits:
-
Object
- Object
- RablRails::Renderer::ViewContext
- 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) ⇒ ViewContext
constructor
A new instance of ViewContext.
- #lookup_context ⇒ Object
- #params ⇒ Object
Constructor Details
#initialize(path, options) ⇒ ViewContext
Returns a new instance of ViewContext.
47 48 49 50 51 52 53 54 |
# File 'lib/rabl-rails/renderer.rb', line 47 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.
45 46 47 |
# File 'lib/rabl-rails/renderer.rb', line 45 def format @format end |
Instance Method Details
#assigns ⇒ Object
56 57 58 |
# File 'lib/rabl-rails/renderer.rb', line 56 def assigns @_assigns end |
#lookup_context ⇒ Object
64 65 66 |
# File 'lib/rabl-rails/renderer.rb', line 64 def lookup_context @lookup_context ||= LookupContext.new(@options[:view_path], format) end |
#params ⇒ Object
60 61 62 |
# File 'lib/rabl-rails/renderer.rb', line 60 def params { format: format } end |