Module: Pult::Panel::App::DotAccessible

Defined in:
lib/init/struct.rb,
lib/pult/panel/app/dot_accessible.rb

Defined Under Namespace

Classes: Job

Constant Summary collapse

RunnerInjector =
Pult::Panel::Runner::Injector
JOB_KEY =
'_job'

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args) ⇒ 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
# File 'lib/pult/panel/app/dot_accessible.rb', line 13

def method_missing meth, *args
  /(?<action>[^\!]+)(?<need_execute>\!?)/ =~ meth.to_s

  for injection in [JOB_KEY] + RunnerInjector.read_injections
    action.gsub! /#{injection}$/, ''
    break if $&
  end

  value = self[action]

  if !need_execute.blank?
    if value.respond_to? :app?
      with_job? $& do
        for sub_action in value.keys
          value.send "#{sub_action}!", *args
        end
      end
    else
      return execute!(action, $&, *args)
    end
  end

  $& ? nil : value
end