Class: Fabrique::BeanDefinition
- Inherits:
-
Object
- Object
- Fabrique::BeanDefinition
- Defined in:
- lib/fabrique/bean_definition.rb
Instance Attribute Summary collapse
-
#constructor_args ⇒ Object
readonly
Returns the value of attribute constructor_args.
-
#factory_method ⇒ Object
readonly
Returns the value of attribute factory_method.
-
#gem ⇒ Object
readonly
Returns the value of attribute gem.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #dependencies ⇒ Object
-
#initialize(attrs = {}) ⇒ BeanDefinition
constructor
A new instance of BeanDefinition.
- #singleton? ⇒ Boolean
Constructor Details
#initialize(attrs = {}) ⇒ BeanDefinition
Returns a new instance of BeanDefinition.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fabrique/bean_definition.rb', line 6 def initialize(attrs = {}) @id = attrs["id"] @type = attrs["class"] @gem = GemDefinition.new(attrs["gem"]) if attrs["gem"] @constructor_args = attrs["constructor_args"] || [] @constructor_args = keywordify(@constructor_args) if @constructor_args.is_a?(Hash) @properties = attrs["properties"] || {} @scope = attrs["scope"] || "singleton" @factory_method = attrs["factory_method"] || "new" end |
Instance Attribute Details
#constructor_args ⇒ Object (readonly)
Returns the value of attribute constructor_args.
4 5 6 |
# File 'lib/fabrique/bean_definition.rb', line 4 def constructor_args @constructor_args end |
#factory_method ⇒ Object (readonly)
Returns the value of attribute factory_method.
4 5 6 |
# File 'lib/fabrique/bean_definition.rb', line 4 def factory_method @factory_method end |
#gem ⇒ Object (readonly)
Returns the value of attribute gem.
4 5 6 |
# File 'lib/fabrique/bean_definition.rb', line 4 def gem @gem end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/fabrique/bean_definition.rb', line 4 def id @id end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
4 5 6 |
# File 'lib/fabrique/bean_definition.rb', line 4 def properties @properties end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/fabrique/bean_definition.rb', line 4 def type @type end |
Instance Method Details
#dependencies ⇒ Object
17 18 19 |
# File 'lib/fabrique/bean_definition.rb', line 17 def dependencies (accumulate_dependencies(@type) + accumulate_dependencies(@constructor_args) + accumulate_dependencies(@properties)).uniq end |
#singleton? ⇒ Boolean
21 22 23 |
# File 'lib/fabrique/bean_definition.rb', line 21 def singleton? @scope == "singleton" end |