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 {|@config| ... } ⇒ Server

Returns a new instance of Server.

Yields:

  • (@config)

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
# File 'lib/filemaker/server.rb', line 18

def initialize
  @config = Configuration.new
  yield @config if block_given?
  raise ArgumentError, 'Missing config block' if @config.not_configurable?

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

Instance Attribute Details

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

Returns the database store.

Returns:



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

def databases
  @databases
end

Instance Method Details

#handler_namesObject



79
80
81
# File 'lib/filemaker/server.rb', line 79

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

#perform_request(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

Returns:

  • (Array)

    response and request params Hash



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/filemaker/server.rb', line 34

def perform_request(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 = get_typhoeus_connection(params)

  http_status = "#{response.response_code}:#{response.return_code}"

  case response.response_code
  when 200
    [response, params]
  when 401
    raise Errors::AuthenticationError,
          "[#{http_status}] Authentication failed."
  when 0
    if response.return_code == :operation_timedout
      raise Errors::HttpTimeoutError,
            "[#{http_status}] Current timeout value is #{timeout}"
    else
      raise Errors::CommunicationError,
            "[#{http_status}] Empty response."
    end
  when 404
    raise Errors::CommunicationError,
          "[#{http_status}] Not found"
  when 302
    raise Errors::CommunicationError,
          "[#{http_status}] Redirect not supported"
  when 502
    raise Errors::CommunicationError,
          "[#{http_status}] Bad gateway. Too many records."
  else
    msg = "Unknown response code = #{http_status}"
    raise Errors::CommunicationError, msg
  end
end