Class: Moonshot::DynamicTemplate::Parameters

Inherits:
Object
  • Object
show all
Defined in:
lib/moonshot/dynamic_template.rb

Overview

A class to encapsulate template parameters, passing a hash to ‘process` is only available from Ruby 2.5.

Instance Method Summary collapse

Constructor Details

#initialize(parameters) ⇒ Parameters

Returns a new instance of Parameters.



13
14
15
16
17
18
19
20
# File 'lib/moonshot/dynamic_template.rb', line 13

def initialize(parameters)
  parameters.each do |k, v|
    instance_variable_set("@#{k}".to_sym, v)
    # Adding an attribute reader for flexibility, this way you can add
    # either `@parameter` or just `parameter` to your template.
    self.class.send(:attr_reader, k.to_sym)
  end
end

Instance Method Details

#expose_bindingObject



22
23
24
# File 'lib/moonshot/dynamic_template.rb', line 22

def expose_binding
  binding
end