Class: OSC::Reservations::Batch

Inherits:
Object
  • Object
show all
Defined in:
lib/osc/reservations/batch.rb

Overview

Batch server that utilizes reservations in the batch scheduler.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, context = {}) ⇒ Batch

Returns a new instance of Batch.

Parameters:

  • server (String)

    The server to connect to.

  • context (Hash) (defaults to: {})

    An optional hash of values that may be required by chosen adapter.



10
11
12
13
14
15
16
17
18
# File 'lib/osc/reservations/batch.rb', line 10

def initialize(server, context = {})
  @server = server

  # symbolize keys
  @context = {}
  context.each do |key, value|
    @context[key.to_sym] = value
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

See if the method call exists as a key in @context.

Parameters:

  • method_name

    the method name called

  • arguments

    the arguments to the call

  • block

    an optional block for the call



25
26
27
# File 'lib/osc/reservations/batch.rb', line 25

def method_missing(method_name, *arguments, &block)
  @context.fetch(method_name) { super }
end

Instance Attribute Details

#serverString (readonly)

Returns the batch server to connect to.

Returns:

  • (String)

    the batch server to connect to.



6
7
8
# File 'lib/osc/reservations/batch.rb', line 6

def server
  @server
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Checks if the method responds to an instance method, or is able to proxy it to @context.

Parameters:

  • method_name

    the method name to check

Returns:

  • (Boolean)


34
35
36
# File 'lib/osc/reservations/batch.rb', line 34

def respond_to_missing?(method_name, include_private = false)
  @context.include?(method_name) || super
end