Class: Passpartu::Verify
- Inherits:
-
Object
- Object
- Passpartu::Verify
- Defined in:
- lib/passpartu/verify.rb
Direct Known Subclasses
Constant Summary collapse
- CRUD_KEY =
'crud'
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#except ⇒ Object
readonly
Returns the value of attribute except.
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#only ⇒ Object
readonly
Returns the value of attribute only.
-
#policy_hash ⇒ Object
readonly
Returns the value of attribute policy_hash.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
Class Method Summary collapse
- .call(role, keys, only: nil, except: nil, skip: nil, policy_hash: Passpartu.policy, &block) ⇒ Object
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(role, keys, only, except, skip, policy_hash, &block) ⇒ Verify
constructor
A new instance of Verify.
Constructor Details
#initialize(role, keys, only, except, skip, policy_hash, &block) ⇒ Verify
Returns a new instance of Verify.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/passpartu/verify.rb', line 9 def initialize(role, keys, only, except, skip, policy_hash, &block) exclusion = except || skip # alias @role = role.to_s @keys = keys.map(&:to_s) @only = Array(only).map(&:to_s) if present?(only) @except = Array(exclusion).map(&:to_s) if present?(exclusion) && !@only @block = block @policy_hash = deep_stringify_keys(policy_hash) raise PolicyYmlNotFoundError if Passpartu.policy.nil? end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
7 8 9 |
# File 'lib/passpartu/verify.rb', line 7 def block @block end |
#except ⇒ Object (readonly)
Returns the value of attribute except.
7 8 9 |
# File 'lib/passpartu/verify.rb', line 7 def except @except end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
7 8 9 |
# File 'lib/passpartu/verify.rb', line 7 def keys @keys end |
#only ⇒ Object (readonly)
Returns the value of attribute only.
7 8 9 |
# File 'lib/passpartu/verify.rb', line 7 def only @only end |
#policy_hash ⇒ Object (readonly)
Returns the value of attribute policy_hash.
7 8 9 |
# File 'lib/passpartu/verify.rb', line 7 def policy_hash @policy_hash end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
7 8 9 |
# File 'lib/passpartu/verify.rb', line 7 def result @result end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
7 8 9 |
# File 'lib/passpartu/verify.rb', line 7 def role @role end |
Class Method Details
.call(role, keys, only: nil, except: nil, skip: nil, policy_hash: Passpartu.policy, &block) ⇒ Object
22 23 24 |
# File 'lib/passpartu/verify.rb', line 22 def self.call(role, keys, only: nil, except: nil, skip: nil, policy_hash: Passpartu.policy, &block) new(role, keys, only, except, skip, policy_hash, &block).call end |
Instance Method Details
#call ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/passpartu/verify.rb', line 26 def call return false if role_ignore? default_check check_crud_if validate_result rescue StandardError => e if ['TrueClass does not have #dig method', 'FalseClass does not have #dig method'].include?(e.) raise WaterfallError, "Looks like you want to use check_waterfall feature, but it's set to 'false'. Otherwise check your #{Passpartu.config.policy_file} for validness" else raise e end end |