Module: TrustedKeys::ClassMethods

Defined in:
lib/trusted_keys.rb

Instance Method Summary collapse

Instance Method Details

#trust(*args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/trusted_keys.rb', line 11

def trust(*args)
  options = args.extract_options!
  scope = options.fetch(:for, "").to_s.split '.'
  env = options[:env] || Rails.env
  nested = options.fetch(:nested, true)

  klass = Class.new do
    include Trustable
  end

  @_trusted_keys ||= []
  @_trusted_keys << klass.new(:scope => scope,
                              :trusted_keys => @_trusted_keys,
                              :untrusted => Error::NotTrusted.new(env),
                              :nested => nested,
                              :keys => args)
end