class Fabrique::YamlBeanFactory
Public Class Methods
new(path_or_string)
click to toggle source
Calls superclass method
Fabrique::BeanFactory::new
# File lib/fabrique/yaml_bean_factory.rb, line 28 def initialize(path_or_string) super bean_definition_registry beans_node load_yaml path_or_string end
Private Instance Methods
bean_definition_registry(beans)
click to toggle source
# File lib/fabrique/yaml_bean_factory.rb, line 50 def bean_definition_registry(beans) if beans.is_a?(BeanDefinitionRegistry) beans elsif beans.is_a?(Array) BeanDefinitionRegistry.new(beans) else raise "YAML top-level beans node must be an Array or a #{BeanDefinitionRegistry}" end end
beans_node(parsed_yaml)
click to toggle source
# File lib/fabrique/yaml_bean_factory.rb, line 42 def beans_node(parsed_yaml) if parsed_yaml.respond_to?(:keys) and parsed_yaml["beans"] parsed_yaml["beans"] else raise "YAML contains no top-level beans node" end end
load_yaml(path_or_string)
click to toggle source
# File lib/fabrique/yaml_bean_factory.rb, line 34 def load_yaml(path_or_string) if path_or_string.is_a?(String) and path_or_string =~ /\A---\r?\n/ YAML.load(path_or_string) else YAML.load_file(path_or_string) end end