Sha256: ee8a61b0159168f11a46605e7b7336f1a639aae7b7bae96c07b275b07f75f45a

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

module PolicyManager
  class Config

    mattr_accessor :exporter, 
                   :from_email, 
                   :is_admin_method,
                   :logout_url, 
                   :user_language_method,
                   :scripts

    def self.setup
      @@rules = []
      @@portability_rules = []
      @@portability_templates = []
      @@scripts = []
      yield self
      self
    end
    
    def self.exporter=(opts)
      @@exporter = Exporter.new(opts)
    end

    def self.is_admin?(user)
      @@is_admin_method.call(user)
    end

    def self.user_language(user)
      @@user_language_method.call(user) rescue :en
    end

    def self.rules
      @@rules ||= []
    end

    def self.portability_rules
      @@portability_rules ||= []
    end

    def self.add_rule(opts={}, &block)
      @@rules << PolicyManager::Rule.new(opts, &block)
    end

    def self.add_portability_rule(opts={}, &block)
      @@portability_rules << PolicyManager::PortabilityRule.new(opts, &block)
    end

    def self.add_script(opts={}, &block)
      @@scripts << PolicyManager::Script.new(opts, &block)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gdpr_rails-0.2.0 lib/policy_manager/config.rb