Class: Filemaker::Server
- Inherits:
-
Object
- Object
- Filemaker::Server
- Extended by:
- Forwardable
- Defined in:
- lib/filemaker/server.rb
Instance Attribute Summary collapse
-
#connection ⇒ Faraday::Connection
readonly
The HTTP connection.
-
#databases ⇒ Filemaker::Store::DatabaseStore
(also: #database, #db)
readonly
The database store.
Instance Method Summary collapse
- #handler_names ⇒ Object
-
#initialize(options = {}) {|@config| ... } ⇒ Server
constructor
A new instance of Server.
-
#perform_request(method, action, args, options = {}) ⇒ Array
private
Mostly used by Filemaker::Api TODO: There must be tracing/instrumentation.
Constructor Details
permalink #initialize(options = {}) {|@config| ... } ⇒ Server
Returns a new instance of Server.
20 21 22 23 24 25 26 27 |
# File 'lib/filemaker/server.rb', line 20 def initialize( = {}) @config = Configuration.new yield @config if block_given? raise ArgumentError, 'Missing config block' if @config.not_configurable? @databases = Store::DatabaseStore.new(self) @connection = get_connection() end |
Instance Attribute Details
permalink #connection ⇒ Faraday::Connection (readonly)
Returns the HTTP connection.
10 11 12 |
# File 'lib/filemaker/server.rb', line 10 def connection @connection end |
permalink #databases ⇒ Filemaker::Store::DatabaseStore (readonly) Also known as: database, db
Returns the database store.
13 14 15 |
# File 'lib/filemaker/server.rb', line 13 def databases @databases end |
Instance Method Details
permalink #handler_names ⇒ Object
[View source]
74 75 76 |
# File 'lib/filemaker/server.rb', line 74 def handler_names @connection.builder.handlers.map(&:name) end |
permalink #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 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/filemaker/server.rb', line 37 def perform_request(method, action, args, = {}) params = serialize_args(args) .merge(()) .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 [response, params] when 401 raise Errors::AuthenticationError, "[#{response.status}] Authentication failed." when 0 raise Errors::CommunicationError, "[#{response.status}] Empty response." when 404 raise Errors::CommunicationError, "[#{response.status}] Not found" when 302 raise Errors::CommunicationError, "[#{response.status}] Redirect not supported" when 502 raise Errors::CommunicationError, "[#{response.status}] Bad gateway. Too many records." else msg = "Unknown response status = #{response.status}" raise Errors::CommunicationError, msg end end |