Class: Rox::Core::Registerer
- Inherits:
-
Object
- Object
- Rox::Core::Registerer
- Defined in:
- lib/rox/core/register/registerer.rb
Instance Method Summary collapse
-
#initialize(flag_repository) ⇒ Registerer
constructor
A new instance of Registerer.
- #register_instance(container, ns) ⇒ Object
Constructor Details
#initialize(flag_repository) ⇒ Registerer
Returns a new instance of Registerer.
4 5 6 7 8 |
# File 'lib/rox/core/register/registerer.rb', line 4 def initialize(flag_repository) @flag_repository = flag_repository @namespaces = [] @mutex = Mutex.new end |
Instance Method Details
#register_instance(container, ns) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rox/core/register/registerer.rb', line 10 def register_instance(container, ns) raise ArgumentError, 'A namespace cannot be null' if ns.nil? @mutex.synchronize do raise ArgumentError, "A container with the given namespace (#{ns}) has already been registered" if @namespaces.include?(ns) end @namespaces << ns container.methods.each do |method_name| method = container.method(method_name) next unless method.arity.zero? begin value = method.call if value.is_a?(Variant) @flag_repository.add_flag(value, ns == '' ? method_name.to_s : "#{ns}.#{method_name}") end rescue StandardError next end end end |