Module: Surrounded::Context::InstanceMethods

Defined in:
lib/surrounded/context.rb

Instance Method Summary collapse

Instance Method Details

#role?(name, &block) ⇒ Boolean

Check whether a given name is a role inside the context. The provided block is used to evaluate whether or not the caller is allowed to inquire about the roles.

Returns:

  • (Boolean)


225
226
227
228
229
# File 'lib/surrounded/context.rb', line 225

def role?(name, &block)
  return false unless role_map.role?(name)
  accessor = block.binding.eval('self')
  role_map.role_player?(accessor) && role_map.assigned_player(name)
end

#role_player?(obj) ⇒ Boolean

Check if a given object is a role player in the context.

Returns:

  • (Boolean)


232
233
234
# File 'lib/surrounded/context.rb', line 232

def role_player?(obj)
  role_map.role_player?(obj)
end

#triggersObject



236
237
238
# File 'lib/surrounded/context.rb', line 236

def triggers
  self.class.triggers
end