Module: Surrounded::AccessControl::AccessMethods
- Defined in:
- lib/surrounded/access_control.rb
Instance Method Summary collapse
-
#all_triggers ⇒ Object
Return a Set of all defined triggers regardless of any disallow blocks.
-
#allow?(name) ⇒ Boolean
Ask if the context will allow access to a trigger given the current players.
-
#triggers ⇒ Object
Return a Set of triggers which may be run according to any restrictions defined in disallow blocks.
Instance Method Details
#all_triggers ⇒ Object
Return a Set of all defined triggers regardless of any disallow blocks
49 50 51 |
# File 'lib/surrounded/access_control.rb', line 49 def all_triggers self.class.triggers end |
#allow?(name) ⇒ Boolean
Ask if the context will allow access to a trigger given the current players.
62 63 64 65 66 |
# File 'lib/surrounded/access_control.rb', line 62 def allow?(name) raise NoMethodError, %(undefined method `#{name}' for #{inspect}) unless respond_to?(name) predicate = "disallow_#{name}?" !respond_to?(predicate) || !public_send(predicate) end |
#triggers ⇒ Object
Return a Set of triggers which may be run according to any restrictions defined in disallow blocks.
55 56 57 58 59 |
# File 'lib/surrounded/access_control.rb', line 55 def triggers all_triggers.select { |name| allow?(name) }.to_set end |