3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/shoes/widget.rb', line 3
def self.inherited klass, &blk
m = klass.to_s[/(^|::)(\w+)$/, 2].
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
Shoes::App.class_eval do
define_method m do |*args, &blk|
klass.class_variable_set :@@__app__, self
parent = app.cslot
klass.new(*args, &blk).tap do |s|
s.define_singleton_method(:parent){parent}
end
end
end
klass.class_eval do
define_method :method_missing do |*args, &blk|
klass.class_variable_get(:@@__app__).send *args, &blk
end
end
end
|