Sha256: 8c9fca5681806666e82d90e829af94aac41242d4fa008e20a0879f7707f8bd3a

Contents?: true

Size: 1.13 KB

Versions: 8

Compression:

Stored size: 1.13 KB

Contents

require "active_support/all"
require "i18n"

require "protector/version"
require "protector/dsl"
require "protector/adapters/active_record"
require "protector/adapters/sequel"

require "protector/engine" if defined?(Rails)

I18n.load_path += Dir[File.expand_path File.join('..', 'locales', '*.yml'), File.dirname(__FILE__)]

module Protector
  class << self
    ADAPTERS = [
      Protector::Adapters::ActiveRecord,
      Protector::Adapters::Sequel
    ]

    attr_accessor :config

    def paranoid=
      "`Protector.paranoid = ...` is deprecated! Please change it to `Protector.config.paranoid = ...`"
    end

    # 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

  class Config < ActiveSupport::OrderedOptions
    def paranoid?
      !!paranoid
    end

    def strong_parameters?
      strong_parameters == nil || !!strong_parameters
    end
  end

  self.config = Config.new
end

Protector.activate!

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
protector-0.6.1 lib/protector.rb
protector-0.6.0 lib/protector.rb
protector-0.6.0.beta.1 lib/protector.rb
protector-0.5.5 lib/protector.rb
protector-0.5.4 lib/protector.rb
protector-0.5.3 lib/protector.rb
protector-0.5.2 lib/protector.rb
protector-0.5.1 lib/protector.rb