Class: Moonshot::DynamicTemplate::Parameters
- Inherits:
-
Object
- Object
- Moonshot::DynamicTemplate::Parameters
- 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
- #expose_binding ⇒ Object
-
#initialize(parameters) ⇒ Parameters
constructor
A new instance of Parameters.
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_binding ⇒ Object
22 23 24 |
# File 'lib/moonshot/dynamic_template.rb', line 22 def expose_binding binding end |