Class: Fabrique::BeanDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/fabrique/bean_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_argsObject (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_methodObject (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

#gemObject (readonly)

Returns the value of attribute gem.



4
5
6
# File 'lib/fabrique/bean_definition.rb', line 4

def gem
  @gem
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/fabrique/bean_definition.rb', line 4

def id
  @id
end

#propertiesObject (readonly)

Returns the value of attribute properties.



4
5
6
# File 'lib/fabrique/bean_definition.rb', line 4

def properties
  @properties
end

#typeObject (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

#dependenciesObject



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

Returns:

  • (Boolean)


21
22
23
# File 'lib/fabrique/bean_definition.rb', line 21

def singleton?
  @scope == "singleton"
end