Method: Nanoc::Core::Context#initialize
- Defined in:
- lib/nanoc/core/context.rb
#initialize(hash) ⇒ Context
Creates a new context based off the contents of the hash.
Each pair in the hash will be converted to an instance variable and an instance method. For example, passing the hash ‘{ :foo => ’bar’ }‘ will cause `@foo` to have the value `“bar”`, and the instance method #foo to return the same value `“bar”`.
27 28 29 30 31 |
# File 'lib/nanoc/core/context.rb', line 27 def initialize(hash) hash.each_pair do |key, value| instance_variable_set('@' + key.to_s, value) end end |