Class: Filemaker::Server

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/filemaker/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|@config| ... } ⇒ Server

Returns a new instance of Server.

Yields:

  • (@config)


20
21
22
23
24
25
26
27
# File 'lib/filemaker/server.rb', line 20

def initialize(options = {})
  @config = Configuration.new
  yield @config if block_given?
  fail ArgumentError, 'Missing config block' if @config.not_configurable?

  @databases = Store::DatabaseStore.new(self)
  @connection = get_connection(options)
end

Instance Attribute Details

#connectionFaraday::Connection (readonly)



10
11
12
# File 'lib/filemaker/server.rb', line 10

def connection
  @connection
end

#databasesFilemaker::Store::DatabaseStore (readonly) Also known as: database, db



13
14
15
# File 'lib/filemaker/server.rb', line 13

def databases
  @databases
end

Instance Method Details

#handler_namesObject



62
63
64
# File 'lib/filemaker/server.rb', line 62

def handler_names
  @connection.builder.handlers.map(&:name)
end

#perform_request(method, action, args, options = {}) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Mostly used by Filemaker::Api TODO: There must be tracing/instrumentation. CURL etc. Or performance metrics? Also we want to pass in timeout option so we can ignore timeout for really long requests



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/filemaker/server.rb', line 37

def perform_request(method, action, args, options = {})
  params = serialize_args(args)
    .merge(expand_options(options))
    .merge({ action => '' })

  # Serialize the params for submission??
  params.stringify_keys!

  log_action(params)

  # yield params if block_given?
  response = @connection.public_send(method, endpoint, params)

  case response.status
  when 200 then [response, params]
  when 401 then fail Errors::AuthenticationError, 'Auth failed.'
  when 0   then fail Errors::CommunicationError, 'Empty response.'
  when 404 then fail Errors::CommunicationError, 'HTTP 404 Not Found'
  when 302 then fail Errors::CommunicationError, 'Redirect not supported'
  else
    msg = "Unknown response status = #{response.status}"
    fail Errors::CommunicationError, msg
  end
end