Class: AccessAllow::Check
- Inherits:
-
Object
- Object
- AccessAllow::Check
- Defined in:
- lib/access_allow/check.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(user, ability_namespace, ability_name) ⇒ Check
constructor
A new instance of Check.
- #possible! ⇒ Object
- #possible? ⇒ Boolean
Constructor Details
#initialize(user, ability_namespace, ability_name) ⇒ Check
Returns a new instance of Check.
22 23 24 25 26 27 |
# File 'lib/access_allow/check.rb', line 22 def initialize(user, ability_namespace, ability_name) @user = user @ability_manager = user ? AccessAllow::AbilitiesManager.new(user) : nil @ability_namespace = ability_namespace.to_sym @ability_name = ability_name.to_sym end |
Class Method Details
.call(user, config) ⇒ Object
6 7 8 |
# File 'lib/access_allow/check.rb', line 6 def call(user, config) build_perms_checker(user, config).possible? end |
.call!(user, config) ⇒ Object
10 11 12 |
# File 'lib/access_allow/check.rb', line 10 def call!(user, config) build_perms_checker(user, config).possible! end |
Instance Method Details
#possible! ⇒ Object
37 38 39 |
# File 'lib/access_allow/check.rb', line 37 def possible! possible? || raise(AccessAllow::ViolationError, (false)) end |
#possible? ⇒ Boolean
29 30 31 32 33 34 35 |
# File 'lib/access_allow/check.rb', line 29 def possible? unless user Rails.logger.info (false) return false end ability_manager.has?(ability_namespace, ability_name).tap { |can| Rails.logger.info (can) unless can } end |