Class: Ocular::DSL::RunContext

Inherits:
Object
  • Object
show all
Includes:
Etcd, Fog, Logging, MySQL, Orbit, RabbitMQ, SSH, Inputs::Cron::DSL
Defined in:
lib/ocular/dsl/runcontext.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Inputs::Cron::DSL

#cron

Methods included from RabbitMQ

#amqp

Methods included from MySQL

#mysql

Methods included from Orbit

#orbit

Methods included from Etcd

#etcd

Methods included from Fog

#autoscaling, #aws, #find_server_by_ip, #find_servers_in_autoscaling_groups

Methods included from SSH

#ssh_to

Methods included from Logging

#debug, #error, #fatal, #info, #log_cause, #log_event, #log_timing, #warn

Constructor Details

#initialize(logger) ⇒ RunContext

Returns a new instance of RunContext.



23
24
25
26
27
# File 'lib/ocular/dsl/runcontext.rb', line 23

def initialize(logger)
    @run_id = SecureRandom.uuid()
    @logger = logger
    @cleanups = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/ocular/dsl/runcontext.rb', line 29

def method_missing(method_sym, *arguments, &block)
    if self.proxy
        self.proxy.send(method_sym, *arguments, &block)
    else
        raise NoMethodError, "undefined method `#{method_sym}` in event #{self.class_name}"
    end
end

Instance Attribute Details

#class_nameObject

Returns the value of attribute class_name.



10
11
12
# File 'lib/ocular/dsl/runcontext.rb', line 10

def class_name
  @class_name
end

#event_signatureObject

Returns the value of attribute event_signature.



11
12
13
# File 'lib/ocular/dsl/runcontext.rb', line 11

def event_signature
  @event_signature
end

#proxyObject

Returns the value of attribute proxy.



9
10
11
# File 'lib/ocular/dsl/runcontext.rb', line 9

def proxy
  @proxy
end

#run_idObject

Returns the value of attribute run_id.



8
9
10
# File 'lib/ocular/dsl/runcontext.rb', line 8

def run_id
  @run_id
end

Instance Method Details

#cleanupObject



41
42
43
44
45
# File 'lib/ocular/dsl/runcontext.rb', line 41

def cleanup()
    for i in @cleanups
        i.call()
    end
end

#register_cleanup(&block) ⇒ Object



37
38
39
# File 'lib/ocular/dsl/runcontext.rb', line 37

def register_cleanup(&block)
    @cleanups << block
end