34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/goocanvas.rb', line 34
def self.append_features(klass)
super
arity = klass.instance_method(:initialize).arity
raise 'the initialize method of a class including PropsInit must have a fixed arity' if arity < 0
args_list = (1..arity).collect { |i| "param#{i}" }.join(", ")
klass.module_eval <<-END
alias :_initialize :initialize
def initialize(#{args_list}, *args)
_initialize(#{args_list})
init_props(*args)
end
alias :_set_property :set_property
def set_property(prop_name, value)
pspec = self.class.property(prop_name)
value = value.to_goo if pspec.value_type.name =~ /^GooCairo/ and value.respond_to?(:to_goo)
_set_property(prop_name, value)
end
END
end
|