Module: Surrounded::Context::InstanceMethods
- Defined in:
- lib/surrounded/context.rb
Instance Method Summary collapse
- #rebind(options_hash) ⇒ Object
-
#role?(name, &block) ⇒ Boolean
Check whether a given name is a role inside the context.
-
#role_player?(obj) ⇒ Boolean
Check if a given object is a role player in the context.
-
#triggers ⇒ Object
Return a Set of all defined triggers.
Instance Method Details
#rebind(options_hash) ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/surrounded/context.rb', line 132 def rebind() clear_instance_variables initialize(**) rescue ArgumentError initialize(*.values) self end |
#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.
116 117 118 119 120 |
# File 'lib/surrounded/context.rb', line 116 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.
123 124 125 |
# File 'lib/surrounded/context.rb', line 123 def role_player?(obj) role_map.role_player?(obj) end |
#triggers ⇒ Object
Return a Set of all defined triggers
128 129 130 |
# File 'lib/surrounded/context.rb', line 128 def triggers self.class.triggers end |