module Surrounded::AccessControl::AccessMethods

Public Instance Methods

all_triggers() click to toggle source

Return a Set of all defined triggers regardless of any disallow blocks

# File lib/surrounded/access_control.rb, line 50
def all_triggers
  self.class.triggers
end
allow?(name) click to toggle source

Ask if the context will allow access to a trigger given the current players.

# File lib/surrounded/access_control.rb, line 64
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() click to toggle source

Return a Set of triggers which may be run according to any restrictions defined in disallow blocks.

# File lib/surrounded/access_control.rb, line 56
def triggers
  all_triggers.select {|name|
    method_restrictor = "disallow_#{name}?"
    !self.respond_to?(method_restrictor, true) || !self.send(method_restrictor)
  }.to_set
end