Module: TMP::DSLCore

Included in:
DSL, InstanceDSL
Defined in:
lib/tmp/deprecated/dsl.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



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
# File 'lib/tmp/deprecated/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?

      return target_obj.__send__ :block, method, *args, &block

    else

      if method =~ /^\w+__path__$/
        return target_obj.__send__ :path, method.to_s.sub!( /__path__$/,"" ),*args
      else
        return target_obj.__send__ :read, method
      end

    end

  end

end

Instance Method Details

#target_obj(obj = nil) ⇒ Object



6
7
8
9
10
11
# File 'lib/tmp/deprecated/dsl.rb', line 6

def target_obj obj=nil

  @target_obj= obj unless obj.nil?
  @target_obj || ::TMP

end