Class: ThinkingTank::Configuration
- Inherits:
-
Object
- Object
- ThinkingTank::Configuration
- Includes:
- Singleton
- Defined in:
- lib/thinkingtank/init.rb
Instance Attribute Summary collapse
-
#app_root ⇒ Object
Returns the value of attribute app_root.
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #environment ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/thinkingtank/init.rb', line 32 def initialize self.app_root = Rails.root if defined?(Rails.root) self.app_root = RAILS_ROOT if defined?(RAILS_ROOT) self.app_root = Merb.root if defined?(Merb) self.app_root ||= Dir.pwd path = "#{app_root}/config/indextank.yml" return unless File.exists?(path) conf = YAML::load(ERB.new(IO.read(path)).result)[environment] api_url = ENV['INDEXTANK_API_URL'] || conf['api_url'] index_name = conf['index_name'] || 'default_index' self.client = IndexTank::Client.new(api_url).indexes(index_name) end |
Instance Attribute Details
#app_root ⇒ Object
Returns the value of attribute app_root.
31 32 33 |
# File 'lib/thinkingtank/init.rb', line 31 def app_root @app_root end |
#client ⇒ Object
Returns the value of attribute client.
31 32 33 |
# File 'lib/thinkingtank/init.rb', line 31 def client @client end |
Instance Method Details
#environment ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/thinkingtank/init.rb', line 46 def environment if defined?(Merb) Merb.environment elsif defined?(Rails.env) Rails.env elsif defined?(RAILS_ENV) RAILS_ENV else ENV['RAILS_ENV'] || 'development' end end |