Module: Shaf::Helpers
- Defined in:
- lib/shaf/extensions/log.rb,
lib/shaf/extensions/authorize.rb
Instance Method Summary collapse
- #authorize(action, resource = nil) ⇒ Object
- #authorize!(action, resource = nil) ⇒ Object
- #log ⇒ Object
Instance Method Details
#authorize(action, resource = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/shaf/extensions/authorize.rb', line 21 def (action, resource = nil) policy = policy(resource) raise Authorize::NoPolicyError unless policy method = __method_for(action) return policy.public_send(method) if policy.respond_to? method raise Authorize::MissingPolicyAction, "#{policy.class} does not implement method #{method}" end |
#authorize!(action, resource = nil) ⇒ Object
32 33 34 |
# File 'lib/shaf/extensions/authorize.rb', line 32 def (action, resource = nil) (action, resource) or raise Authorize::PolicyViolationError end |
#log ⇒ Object
15 16 17 |
# File 'lib/shaf/extensions/log.rb', line 15 def log self.class.log end |