Class: Shark::MailingService::Renderers::Context
- Inherits:
-
Object
- Object
- Shark::MailingService::Renderers::Context
- Extended by:
- Forwardable
- Defined in:
- lib/shark/mailing_service/renderers/context.rb
Instance Attribute Summary collapse
-
#format ⇒ Object
writeonly
Sets the attribute format.
Instance Method Summary collapse
- #binding ⇒ Object
-
#initialize(renderer, locals = {}) ⇒ Context
constructor
A new instance of Context.
- #render(template, locals = {}) ⇒ Object
Constructor Details
#initialize(renderer, locals = {}) ⇒ Context
Returns a new instance of Context.
13 14 15 16 |
# File 'lib/shark/mailing_service/renderers/context.rb', line 13 def initialize(renderer, locals = {}) @locals = locals.symbolize_keys @renderer = renderer end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (protected)
28 29 30 31 32 |
# File 'lib/shark/mailing_service/renderers/context.rb', line 28 def method_missing(name, *args, &block) return super unless respond_to?(name) @locals[name] end |
Instance Attribute Details
#format=(value) ⇒ Object (writeonly)
Sets the attribute format
9 10 11 |
# File 'lib/shark/mailing_service/renderers/context.rb', line 9 def format=(value) @format = value end |
Instance Method Details
#binding ⇒ Object
18 19 20 |
# File 'lib/shark/mailing_service/renderers/context.rb', line 18 def binding super end |
#render(template, locals = {}) ⇒ Object
22 23 24 |
# File 'lib/shark/mailing_service/renderers/context.rb', line 22 def render(template, locals = {}) @renderer.render(template, @format, locals) end |