Module: Checken::User
- Defined in:
- lib/checken/user.rb
Instance Method Summary collapse
- #can?(*args) ⇒ Boolean
-
#check_permission!(permission_path, object_or_options = {}, options_when_object_provided = {}) ⇒ Boolean
Can the user perform the given action?.
Instance Method Details
#can?(*args) ⇒ Boolean
29 30 31 32 33 34 |
# File 'lib/checken/user.rb', line 29 def can?(*args) (*args) true rescue Checken::PermissionDeniedError => e false end |
#check_permission!(permission_path, object_or_options = {}, options_when_object_provided = {}) ⇒ Boolean
Can the user perform the given action?
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/checken/user.rb', line 9 def (, = {}, = {}) if .is_a?(Hash) object = nil = else object = = end schema = .delete(:schema) || Checken.current_schema || Checken::Schema.instance if schema.nil? raise Error, "Could not determine a schema. Make sure you set Checken.current_schema or pass :schema to can? methods." end strict = .delete(:strict) { true } user_proxy = schema.config.user_proxy_class.new(self) schema.(, user_proxy, object, strict: strict) end |