Module: FmRest::Spyke::Model::ScriptExecution

Extended by:
ActiveSupport::Concern
Included in:
FmRest::Spyke::Model
Defined in:
lib/fmrest/spyke/model/script_execution.rb

Overview

This module adds and extends various ORM features in Spyke models, including custom query methods, remote script execution and exception-raising persistence methods.

Class Method Summary collapse

Class Method Details

.execute(script_name, param = nil) ⇒ FmRest::Spyke::ScriptResult

Requests execution of a FileMaker script, returning its result object.

Examples:

response = MyLayout.execute("Uppercasing Script", "hello")

response.result   # => "HELLO"
response.error    # => "0"
response.success? # => true

Parameters:

  • script_name (String)

    the name of the FileMaker script to execute

  • param (String) (defaults to: nil)

    an optional paramater for the script

Returns:



30
31
32
33
34
35
36
37
38
# File 'lib/fmrest/spyke/model/script_execution.rb', line 30

def execute(script_name, param = nil)
  # Allow keyword argument format for compatibility with execute_script
  if param.respond_to?(:has_key?) && param.has_key?(:param)
    param = param[:param]
  end

  response = execute_script(script_name, param: param)
  response..script.after
end

.execute_script(script_name, param: nil) ⇒ Object

Requests execution of a FileMaker script, returning the entire response object.

The execution results will be in response.metadata.script.after

In general you'd want to use the simpler .execute instead of this method, as it provides more direct access to the script results.

Examples:

response = MyLayout.execute_script("My Script", param: "hello")

Parameters:

  • script_name (String)

    the name of the FileMaker script to execute

  • param (String) (defaults to: nil)

    an optional paramater for the script

Returns:

  • the complete response object



56
57
58
59
# File 'lib/fmrest/spyke/model/script_execution.rb', line 56

def execute_script(script_name, param: nil)
  params = param.nil? ? {} : {"script.param" => param}
  request(:get, FmRest::V1::script_path(layout, script_name), params)
end