Method: LWS.setup
- Defined in:
- lib/lws.rb
.setup {|config| ... } ⇒ LWS
Sets up the application API libraries using the provided configuration (see Config).
The API token can be overridden using the LC_LWS_API_TOKEN environment variable. The LWS environment can be overriden using the LC_LWS_ENV environment variable.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/lws.rb', line 78 def self.setup(&block) @@config = Config.new # Override the environment if needed if ENV["LC_LWS_ENV"].present? @@config.environment = ENV["LC_LWS_ENV"].to_sym end # Override the API token if needed (and no custom API token middleware # is used) if ENV["LC_LWS_API_TOKEN"].present? @@config.api_token = ENV["LC_LWS_API_TOKEN"] end yield @@config if config.api_token.blank? and config.api_token_middleware.blank? raise LWS::Errors::ConfigError, "API token or API token middleware is required" end load_app_modules load_stubbing return self end |