Class: ACLSystem2::AccessControl::AccessSentry
- Inherits:
-
Object
- Object
- ACLSystem2::AccessControl::AccessSentry
- Defined in:
- lib/acl_system2/access_control/access_sentry.rb
Instance Method Summary collapse
- #allowed?(action) ⇒ Boolean
-
#initialize(subject, actions = {}) ⇒ AccessSentry
constructor
A new instance of AccessSentry.
Constructor Details
#initialize(subject, actions = {}) ⇒ AccessSentry
Returns a new instance of AccessSentry.
5 6 7 8 9 10 11 |
# File 'lib/acl_system2/access_control/access_sentry.rb', line 5 def initialize(subject, actions={}) @actions = actions.inject({}) do |auth, current| [current.first].flatten.each { |action| auth[action] = current.last } auth end @subject = subject end |
Instance Method Details
#allowed?(action) ⇒ Boolean
13 14 15 16 17 18 19 20 21 |
# File 'lib/acl_system2/access_control/access_sentry.rb', line 13 def allowed?(action) if @actions.has_key? action.to_sym return @subject.access_handler.process(@actions[action.to_sym].dup, @subject.access_context) elsif @actions.has_key? :DEFAULT return @subject.access_handler.process(@actions[:DEFAULT].dup, @subject.access_context) else return true end end |