Skip to content
Browse files

optimization for production mode

  • Loading branch information...
1 parent 58bbc31 commit 292e73f940cc1b9f6a89b8accfac656848ed9f04 @stffn committed Aug 22, 2008
Showing with 3 additions and 3 deletions.
  1. +2 −2 lib/authorization.rb
  2. +1 −1 lib/in_controller.rb
View
4 lib/authorization.rb
@@ -34,7 +34,7 @@ def self.current_user=(user)
# For use in test cases only
def self.ignore_access_control (state = nil) # :nodoc:
@@ignore_access_control = state unless state.nil?
- @@ignore_access_control
+ ENV['RAILS_ENV'] == 'test' and @@ignore_access_control
end
# Authorization::Engine implements the reference monitor. It may be used
@@ -176,7 +176,7 @@ def obligations (privilege, options = {})
# yet. If +dsl_file+ is given, it is passed on to Engine.new and
# a new instance is always created.
def self.instance (dsl_file = nil)
- if dsl_file
+ if dsl_file or ENV['RAILS_ENV'] == 'development'
@@instance = new(dsl_file)
else
@@instance ||= new
View
2 lib/in_controller.rb
@@ -10,7 +10,7 @@ def self.included(base) # :nodoc:
# Returns the Authorization::Engine for the current controller.
def authorization_engine
- @authorization_engine ||= Authorization::Engine.new
+ @authorization_engine ||= Authorization::Engine.instance
end
# If the current user meets the given privilege, permitted_to? returns true

0 comments on commit 292e73f

Please sign in to comment.
Something went wrong with that request. Please try again.