Class: Hashit
- Inherits:
-
Object
- Object
- Hashit
- Defined in:
- lib/aceroute/hashit.rb
Instance Method Summary collapse
-
#initialize(hash) ⇒ Hashit
constructor
A new instance of Hashit.
Constructor Details
#initialize(hash) ⇒ Hashit
Returns a new instance of Hashit.
2 3 4 5 6 7 8 9 |
# File 'lib/aceroute/hashit.rb', line 2 def initialize(hash) hash.nil? ? return : nil hash.each do |k,v| self.instance_variable_set("@#{k}", v.is_a?(Hash) ? Hashit.new(v) : v) self.class.send(:define_method, k, proc{self.instance_variable_get("@#{k}")}) self.class.send(:define_method, "#{k}=", proc{|v| self.instance_variable_set("@#{k}", v)}) end end |