Module: HashExtensions
- Included in:
- Hash
- Defined in:
- lib/benchmark_time/hash_extensions.rb
Instance Method Summary collapse
-
#to_instance_variables(bind, opts = {}) ⇒ Object
experiment to make hash arguments into instance variables.
Instance Method Details
#to_instance_variables(bind, opts = {}) ⇒ Object
experiment to make hash arguments into instance variables
4 5 6 7 8 9 10 |
# File 'lib/benchmark_time/hash_extensions.rb', line 4 def to_instance_variables(bind, opts={}) each do |key, val| bind.eval("@#{key}=#{val.inspect}") # we can build attr_accessor, attr_reader, attr_writers off these options # bind.eval "self.class.class_eval 'attr_reader :foo'"if opts[:define] end end |