class OSC::Reservations::Query
Factory for creating reservation objects that detail the current user’s reservations on the given batch server.
Public Class Methods
See if the method call exists as a key in batch config yaml file. Examples:
Query.glenn() Query.oakley()
@param method_name the method name called @param arguments the arguments to the call @param block an optional block for the call
# File lib/osc/reservations/query.rb, line 16 def self.method_missing(method_name, *arguments, &block) context = Reservations.batch_config[method_name.to_s] if context adapter_type = context['adapter']['type'] batch_server = context['batch'].delete('server') batch_context = context['batch'] a = Object.const_get(adapter_type).new b = Batch.new(batch_server, batch_context) new(a, b) else super end end
@param adapter [Adapter] The adapter used to communicate with the scheduler. @param batch [Batch] The batch server to communicate with.
# File lib/osc/reservations/query.rb, line 41 def initialize(adapter, batch) @adapter = adapter @batch = batch end
Checks if the method responds to an instance method, or is able to proxy it to the batch config yaml file.
@param method_name the method name to check @return [Boolean]
# File lib/osc/reservations/query.rb, line 35 def self.respond_to_missing?(method_name, include_private = false) Reservations.batch_config.include?(method_name.to_s) || super end
Public Instance Methods
Query
the reservation information for a given reservation id. @param id [String] The reservation id to query for. @return [Reservation, nil] The reservation queried for.
# File lib/osc/reservations/query.rb, line 49 def reservation(id) @adapter.query_reservation(@batch, id) end
Query
for all the reservations. @return [Array<Reservation>] A list of reservations for the user.
# File lib/osc/reservations/query.rb, line 55 def reservations @adapter.query_reservations(@batch) end