Skip to content

Commit e4e3e44

Browse files
committed
automatically set hostname based on environment, allow changes via GG.config
1 parent fb0e90b commit e4e3e44

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/esdb/resource.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def initialize(url=nil, options={}, *args)
1515

1616
# REST is DRY! Let's just guess our url..
1717
klass_ep = self.class.to_s.scan(/::(.*?)$/).flatten[0].pluralize.underscore
18-
@url ||= "http://localhost:9292/api/v1/#{klass_ep}"
18+
@url ||= "http://#{GG.config.host}/api/v1/#{klass_ep}"
1919

2020
# For now, various params will trigger a change in the URI
2121
# might want to do it more like Rails in esdb ..not sure yet

lib/gg.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
module GG
2+
class Config < Hash
3+
def initialize(settings = {})
4+
self.merge!(settings)
5+
end
6+
7+
def method_missing(method, *args)
8+
return self[method.to_sym] if has_key?(method.to_sym)
9+
end
10+
end
11+
12+
def self.config
13+
env = ENV['RACK_ENV'] ? ENV['RACK_ENV'] : (ENV['RAILS_ENV'] ? ENV['RAILS_ENV'] : 'development')
14+
@@config ||= Config.new({
15+
:host => env == 'development' ? 'localhost:9292' : 'alpha.esdb.net'
16+
})
17+
end
218
end
319

420
require 'rest_client'

0 commit comments

Comments
 (0)