lib/protector.rb in protector-0.3.2 vs lib/protector.rb in protector-0.3.3
- old
+ new
@@ -6,18 +6,29 @@
require "protector/adapters/active_record"
require "protector/adapters/sequel"
I18n.load_path += Dir[File.expand_path File.join('..', 'locales', '*.yml'), File.dirname(__FILE__)]
-Protector::Adapters::ActiveRecord.activate! if defined?(ActiveRecord)
-Protector::Adapters::Sequel.activate! if defined?(Sequel)
-
module Protector
+ class << self
+ ADAPTERS = [
+ Protector::Adapters::ActiveRecord,
+ Protector::Adapters::Sequel
+ ]
- # Allows executing any code having Protector globally disabled
- def self.insecurely(&block)
- Thread.current[:protector_disabled] = true
- yield
- ensure
- Thread.current[:protector_disabled] = false
+ attr_accessor :paranoid
+
+ # Allows executing any code having Protector globally disabled
+ def insecurely(&block)
+ Thread.current[:protector_disabled] = true
+ yield
+ ensure
+ Thread.current[:protector_disabled] = false
+ end
+
+ def activate!
+ ADAPTERS.each{|adapter| adapter.activate!}
+ end
end
-end
+end
+
+Protector.activate!
\ No newline at end of file