Class: OSC::Reservations::Query
- Inherits:
-
Object
- Object
- OSC::Reservations::Query
- Defined in:
- lib/osc/reservations/query.rb
Overview
Factory for creating reservation objects that detail the current user’s reservations on the given batch server.
Class Method Summary collapse
-
.method_missing(method_name, *arguments, &block) ⇒ Object
See if the method call exists as a key in batch config yaml file.
-
.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 the batch config yaml file.
Instance Method Summary collapse
-
#initialize(adapter, batch) ⇒ Query
constructor
A new instance of Query.
-
#reservation(id) ⇒ Reservation?
Query the reservation information for a given reservation id.
-
#reservations ⇒ Array<Reservation>
Query for all the reservations.
Constructor Details
#initialize(adapter, batch) ⇒ Query
Returns a new instance of Query.
41 42 43 44 |
# File 'lib/osc/reservations/query.rb', line 41 def initialize(adapter, batch) @adapter = adapter @batch = batch end |
Class Method Details
.method_missing(method_name, *arguments, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# 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 |
.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 the batch config yaml file.
35 36 37 |
# 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 |
Instance Method Details
#reservation(id) ⇒ Reservation?
Query the reservation information for a given reservation id.
49 50 51 |
# File 'lib/osc/reservations/query.rb', line 49 def reservation(id) @adapter.query_reservation(@batch, id) end |
#reservations ⇒ Array<Reservation>
Query for all the reservations.
55 56 57 |
# File 'lib/osc/reservations/query.rb', line 55 def reservations @adapter.query_reservations(@batch) end |