Class: Relaxo::QueryServer::Designer

Inherits:
Object
  • Object
show all
Defined in:
lib/relaxo/query_server/designer.rb

Overview

Implements the design document state and interface.

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Designer

Returns a new instance of Designer.



217
218
219
220
# File 'lib/relaxo/query_server/designer.rb', line 217

def initialize(context)
	@context = context
	@documents = {}
end

Instance Method Details

#create(name, attributes) ⇒ Object

Create a new design document.

Parameters:

  • name (String)

    The name of the design document.

  • attributes (Hash)

    The contents of the design document.



228
229
230
# File 'lib/relaxo/query_server/designer.rb', line 228

def create(name, attributes)
	@documents[name] = DesignDocument.new(@context, name, attributes)
end

#run(name, function, arguments) ⇒ Object

Run a function on a given design document.

Parameters:

  • name (String)

    The name of the design document.

  • function (Array)

    A key path to the function to execute.

  • arguments (Array)

    The arguments to provide to the function.

Raises:

  • (ArgumentError)


240
241
242
243
244
245
246
# File 'lib/relaxo/query_server/designer.rb', line 240

def run(name, function, arguments)
	document = @documents[name]
	
	raise ArgumentError.new("Invalid document name #{name}") unless document
	
	document.run(function, arguments)
end