Method: Filemaker.load!

Defined in:
lib/filemaker.rb

.load!(path, environment = :development) ⇒ Object

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.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# 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.   = 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