Class: Zresume::List

Inherits:
Hash
  • Object
show all
Defined in:
lib/zresume/list.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *a, &bl) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/zresume/list.rb', line 3

def method_missing(m, *a, &bl)
    if !bl
        if m.to_s =~ /=$/
            self[$`.intern] = a[0]
        else
            return self[m] if a.empty?
            self[m] ? self[m]=([self[m]].flatten << a[0]) : self[m] = a[0]
        end
    else
        s =  List[:title, a[0]]
        s.instance_eval &bl
        return self[m] = s if !self[m]
        self[m] = [self[m]].flatten << s
    end
end