Class: Shark::MailingService::Renderers::Context

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/shark/mailing_service/renderers/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Parameters:

  • value

    the value to set the attribute format to.



9
10
11
# File 'lib/shark/mailing_service/renderers/context.rb', line 9

def format=(value)
  @format = value
end

Instance Method Details

#bindingObject



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