Module: Zresume::Person::Core

Defined in:
lib/zresume/person.rb

Instance Method Summary collapse

Instance Method Details

#info(*attrs) ⇒ Object

get a metaclass



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/zresume/person.rb', line 21

def info *attrs
    return @info if attrs.empty?

    attr_reader *attrs

    attrs.each do |key|
        metaclass.instance_eval do
            define_method key do |val=nil, &block|
                @info ||= {}
                val = block if !val and block
                @info[key] = val
            end
        end
    end#set class method

    class_eval do
        define_method(:initialize) do
            self.class.info.each do |k, v|
                if v.respond_to? :lambda?
                    s =  Zresume::List[:title, k]
                    s.instance_eval &v
                    v = s
                end
                instance_variable_set("@#{k}", v)
                self.class.info[k] = v
            end
        end
    end#initialize, add the instance variables
end

#metaclassObject



15
16
17
18
19
# File 'lib/zresume/person.rb', line 15

def metaclass
    class << self
        self
    end
end