Class: HonestPubsub::Configuration
- Inherits:
-
Object
- Object
- HonestPubsub::Configuration
- Defined in:
- lib/honest_pubsub/configuration.rb
Constant Summary collapse
- @@conf =
nil
Class Method Summary collapse
- .application_name ⇒ Object
- .configuration ⇒ Object
- .configure_with(environment_name, yaml_file = nil) ⇒ Object
- .environment ⇒ Object
Class Method Details
.application_name ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/honest_pubsub/configuration.rb', line 30 def self.application_name @application_name ||= if defined?(Rails) Rails.application.class.name.to_s.gsub("::Application", '') else 'honest_pubsub' end.downcase end |
.configuration ⇒ Object
12 13 14 15 |
# File 'lib/honest_pubsub/configuration.rb', line 12 def self.configuration self.configure_with(self.environment) if @@conf.nil? @@conf end |
.configure_with(environment_name, yaml_file = nil) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/honest_pubsub/configuration.rb', line 5 def self.configure_with(environment_name, yaml_file = nil) @@yaml_file = yaml_file.nil? ? "config/pubsub.yml" : yaml_file @@all_conf = Hashie::Mash.new(YAML.load_file(@@yaml_file) ) @@conf = @@all_conf[environment_name.to_sym] self end |
.environment ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/honest_pubsub/configuration.rb', line 17 def self.environment val = ENV["RAILS_ENV"] || ENV["RACK_ENV"] val = if val.present? val.to_sym else if defined?(Rails) Rails.env else raise "No environment can be found for configuration!" end end end |