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
52 53 54 |
# File 'lib/surrounded/access_control.rb', line 52 def all_triggers self.class.triggers end |
#allow?(name) ⇒ Boolean
Ask if the context will allow access to a trigger given the current players.
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/surrounded/access_control.rb', line 66 def allow?(name) unless self.respond_to?(name) raise NoMethodError, %{undefined method `#{name}' for #{self.inspect}} end if self.respond_to?("disallow_#{name}?") !self.public_send("disallow_#{name}?") else true end end |
#triggers ⇒ Object
Return a Set of triggers which may be run according to any restrictions defined in disallow blocks.
58 59 60 61 62 63 |
# File 'lib/surrounded/access_control.rb', line 58 def triggers all_triggers.select {|name| method_restrictor = "disallow_#{name}?" !self.respond_to?(method_restrictor, true) || !self.send(method_restrictor) }.to_set end |