Class: PickyGuard::Loader
- Inherits:
-
Object
- Object
- PickyGuard::Loader
- Includes:
- CanCan::Ability
- Defined in:
- lib/picky_guard/loader.rb
Direct Known Subclasses
Instance Method Summary collapse
- #adjust(user, user_role_checker_class, resource_actions_class, role_policies_class) ⇒ Object
- #can(_action = nil, _subject = nil, _conditions = nil, &_block) ⇒ Object
- #cannot(_action = nil, _subject = nil, _conditions = nil, &_block) ⇒ Object
-
#initialize(_user, *resources_whitelist) ⇒ Loader
constructor
A new instance of Loader.
Constructor Details
#initialize(_user, *resources_whitelist) ⇒ Loader
Returns a new instance of Loader.
9 10 11 12 |
# File 'lib/picky_guard/loader.rb', line 9 def initialize(_user, *resources_whitelist) @resources_whitelist = resources_whitelist @statement_policy_map = {} end |
Instance Method Details
#adjust(user, user_role_checker_class, resource_actions_class, role_policies_class) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/picky_guard/loader.rb', line 14 def adjust(user, user_role_checker_class, resource_actions_class, role_policies_class) validate_parameters(user_role_checker_class, resource_actions_class, role_policies_class) policies = gather_policies(user, user_role_checker_class, role_policies_class.new) statements = gather_statements(user, policies, resource_actions_class.new) adjust_statements(statements) end |
#can(_action = nil, _subject = nil, _conditions = nil, &_block) ⇒ Object
21 22 23 |
# File 'lib/picky_guard/loader.rb', line 21 def can(_action = nil, _subject = nil, _conditions = nil, &_block) raise 'You cannot use `can` method directly with PickyGuard.' end |
#cannot(_action = nil, _subject = nil, _conditions = nil, &_block) ⇒ Object
25 26 27 |
# File 'lib/picky_guard/loader.rb', line 25 def cannot(_action = nil, _subject = nil, _conditions = nil, &_block) raise 'You cannot use `cannot` method directly with PickyGuard.' end |