Class HashEval
In: lib/hash_eval.rb
Parent: Object

Copyright: Copyright (c) 2004 Nicolas Despres. All rights reserved. Author: Nicolas Desprès <nicolas.despres@gmail.com>. License: Gnu General Public License. $Id: /w/fey/ruby_ex/trunk/lib/hash_eval.rb 7944 2005-09-06T23:27:27.929371Z ertai $

Methods

Attributes

hash  [R] 

Public Class methods

[Source]

# File lib/hash_eval.rb, line 9
  def initialize(hash={}, &block)
    @hash = hash
    if block_given?
      if block.arity == -1
        instance_eval(&block)
      else
        block[self]
      end
    end
  end

Public Instance methods

[Source]

# File lib/hash_eval.rb, line 22
  def method_missing(meth, *args, &block)
    args << self.class.new(&block).hash if block_given?
    if args.size == 1
      @hash[meth] = args.first
    else
      @hash[meth] = args
    end
  end

[Validate]