13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/tmp/dsl.rb', line 13
def method_missing( method, *args, &block )
if method.to_s.reverse[0] == '='
target_obj.__send__ :write, method.to_s.reverse.sub('=','').reverse, args.first
return args.first
else
unless block.nil?
if File.exist? File.join( target_obj.folder_path, method.to_s )
args[0] ||= "r+"
else
args[0] ||= "w+"
end
File.open( File.join( target_obj.folder_path, method.to_s ), args[0] ,&block)
else
if method =~ /^\w+__path__$/
return target_obj.__send__ :path, method.to_s.sub!( /__path__$/,"" )
else
return target_obj.__send__ :read, method
end
end
end
end
|