Module: Ruote::HashDot

Defined in:
lib/ruote/util/hashdot.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ruote/util/hashdot.rb', line 30

def method_missing(m, *args)

  m = m.to_s

  if m[-1, 1] == '='
    if args.first.nil?
      self.delete(m[0..-2]); nil
    else
      self[m[0..-2]] = args.first
    end
  else
    self[m]
  end
end

Instance Method Details

#dumpObject



45
46
47
48
49
50
51
52
53
54
# File 'lib/ruote/util/hashdot.rb', line 45

def dump

  s = "~~ h ~~\n"
  each do |k, v|
    s << "  * '#{k}' => "
    s << v.inspect
    s << "\n"
  end
  s << "~~ . ~~"
end