lib/nanoc/base/entities/context.rb in nanoc-4.6.0 vs lib/nanoc/base/entities/context.rb in nanoc-4.6.1

- old
+ new

@@ -22,14 +22,12 @@ # context.instance_eval do # "I am #{name} and I am hiding #{@location}." # end # # => "I am Max Payne and I am hiding in a cheap motel." def initialize(hash) - metaclass = class << self; self; end hash.each_pair do |key, value| instance_variable_set('@' + key.to_s, value) - metaclass.send(:define_method, key) { value } end end # Returns a binding for this instance. # @@ -37,9 +35,23 @@ # rubocop:disable Style/AccessorMethodName def get_binding binding end # rubocop:enable Style/AccessorMethodName + + def method_missing(method, *args, &blk) + ivar_name = '@' + method.to_s + if instance_variable_defined?(ivar_name) + instance_variable_get(ivar_name) + else + super + end + end + + def respond_to_missing?(method, include_all) + ivar_name = '@' + method.to_s + instance_variable_defined?(ivar_name) || super + end def include(mod) metaclass = class << self; self; end metaclass.instance_eval { include(mod) } end