lib/roda/plugins/environments.rb in roda-1.2.0 vs lib/roda/plugins/environments.rb in roda-1.3.0
- old
+ new
@@ -43,19 +43,27 @@
def self.configure(app, env=ENV["RACK_ENV"])
app.environment = (env || 'development').to_sym
end
module ClassMethods
- # The current environment for the application, which should be stored
- # as a symbol.
- attr_accessor :environment
-
# If no environments are given or one of the given environments
# matches the current environment, yield the receiver to the block.
def configure(*envs)
if envs.empty? || envs.any?{|s| s == environment}
yield self
end
+ end
+
+ # The current environment for the application, which should be stored
+ # as a symbol.
+ def environment
+ opts[:environment]
+ end
+
+ # Override the environment for the application, instead of using
+ # RACK_ENV.
+ def environment=(v)
+ opts[:environment] = v
end
[:development, :test, :production].each do |env|
define_method("#{env}?"){environment == env}
end