Class: Fabrique::BeanDefinitionRegistry
- Inherits:
-
Object
- Object
- Fabrique::BeanDefinitionRegistry
- Includes:
- TSort
- Defined in:
- lib/fabrique/bean_definition_registry.rb
Instance Method Summary collapse
- #get_definition(bean_name) ⇒ Object
- #get_definitions ⇒ Object
- #get_gem_definitions ⇒ Object
-
#initialize(definitions) ⇒ BeanDefinitionRegistry
constructor
A new instance of BeanDefinitionRegistry.
- #validate! ⇒ Object
Constructor Details
#initialize(definitions) ⇒ BeanDefinitionRegistry
Returns a new instance of BeanDefinitionRegistry.
11 12 13 |
# File 'lib/fabrique/bean_definition_registry.rb', line 11 def initialize(definitions) @defs = definitions.map { |d| d.is_a?(BeanDefinition) ? d : BeanDefinition.new(d) } end |
Instance Method Details
#get_definition(bean_name) ⇒ Object
15 16 17 |
# File 'lib/fabrique/bean_definition_registry.rb', line 15 def get_definition(bean_name) @defs.detect { |d| d.id == bean_name } or raise MissingBeanError.new("missing bean #{bean_name.inspect}") end |
#get_definitions ⇒ Object
19 20 21 |
# File 'lib/fabrique/bean_definition_registry.rb', line 19 def get_definitions @defs end |
#get_gem_definitions ⇒ Object
23 24 25 |
# File 'lib/fabrique/bean_definition_registry.rb', line 23 def get_gem_definitions @defs.collect(&:gem).compact end |
#validate! ⇒ Object
27 28 29 30 31 |
# File 'lib/fabrique/bean_definition_registry.rb', line 27 def validate! tsort rescue TSort::Cyclic => e raise CyclicBeanDependencyError.new(e..gsub(/topological sort failed/, "cyclic bean dependency error")) end |