Module: Surrounded::Context::Seclusion

Included in:
Initializing, RoleBuilders
Defined in:
lib/surrounded/context/seclusion.rb

Instance Method Summary collapse

Instance Method Details

#private_attr_reader(*method_names) ⇒ Object

Create readers for the named methods and make them private. Role names resolve to the current player (original object, or its applied wrapper during a trigger); any other name reads its instance variable.



16
17
18
19
20
21
22
23
# File 'lib/surrounded/context/seclusion.rb', line 16

def private_attr_reader(*method_names)
  method_names.each do |name|
    define_method(name) do
      role_map.role?(name) ? role_map.current_player(name) : instance_variable_get(:"@#{name}")
    end
    private(name)
  end
end

#private_const_set(name, const) ⇒ Object

Set a named constant and make it private



5
6
7
8
9
10
11
# File 'lib/surrounded/context/seclusion.rb', line 5

def private_const_set(name, const)
  unless role_const_defined?(name)
    const = const_set(name, const)
    private_constant name.to_sym
  end
  const
end