module Filemaker

Constants

VERSION

Public Instance Methods

load!(path, environment = :development) click to toggle source

Based on the environment, register the server so we only ever have one instance of Filemaker::Server per named session. The named session will be defined at the `filemaker.yml` config file.

# File lib/filemaker.rb, line 34
def load!(path, environment = :development)
  file_string = ERB.new(File.new(path).read).result
  sessions = YAML.safe_load(file_string)[environment.to_s]
  raise Errors::ConfigurationError, 'Environment wrong?' if sessions.nil?

  sessions.each_pair do |key, value|
    registry[key] = Filemaker::Server.new do |c|
      c.host           = value['host']
      c.account_name   = value['account_name']
      c.password       = value['password']

      c.ssl            = value['ssl'] if value['ssl']
      c.ssl_verifypeer = value['ssl_verifypeer'] if value['ssl_verifypeer']
      c.ssl_verifyhost = value['ssl_verifyhost'] if value['ssl_verifyhost']
      c.log            = value['log'] if value['log']
      c.endpoint       = value['endpoint'] if value['endpoint']
      c.timeout        = value['timeout'] if value['timeout']
    end
  end
end
registry() click to toggle source
# File lib/filemaker.rb, line 55
def registry
  @registry ||= {}
end