Class: Callme::DepMetadata
- Inherits:
-
Object
- Object
- Callme::DepMetadata
- Defined in:
- lib/callme/dep_metadata.rb
Overview
Stores dep specific data: dep class, name, contract, scope and dep dependencies
Defined Under Namespace
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#contract ⇒ Object
readonly
Returns the value of attribute contract.
-
#dep_class ⇒ Object
readonly
Returns the value of attribute dep_class.
-
#factory_method ⇒ Object
readonly
Returns the value of attribute factory_method.
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #fetch_attrs!(klass) ⇒ Object
- #has_contract? ⇒ Boolean
- #has_factory_method? ⇒ Boolean
-
#initialize(name, options, &block) ⇒ DepMetadata
constructor
Constructor here attr means setter injection, arg means constructon injects
some_dependency
is an attr_accessor defined in the dep class,ref
specifies what dependency from container to use to set the attribute.
Constructor Details
#initialize(name, options, &block) ⇒ DepMetadata
Constructor here attr means setter injection, arg means constructon injects some_dependency
is an attr_accessor defined in the dep class, ref
specifies what dependency from container to use to set the attribute
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/callme/dep_metadata.rb', line 17 def initialize(name, , &block) Callme::ArgsValidator.has_key!(, :class) @name = name @dep_class = [:class] @contract = [:contract] @scope = [:scope] || :singleton @instance = [:instance].nil? ? true : [:instance] @factory_method = [:factory_method] @attrs = [] fetch_attrs!(@dep_class) if block Dsl.new(@attrs).instance_exec(&block) end end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
4 5 6 |
# File 'lib/callme/dep_metadata.rb', line 4 def attrs @attrs end |
#contract ⇒ Object (readonly)
Returns the value of attribute contract.
4 5 6 |
# File 'lib/callme/dep_metadata.rb', line 4 def contract @contract end |
#dep_class ⇒ Object (readonly)
Returns the value of attribute dep_class.
4 5 6 |
# File 'lib/callme/dep_metadata.rb', line 4 def dep_class @dep_class end |
#factory_method ⇒ Object (readonly)
Returns the value of attribute factory_method.
4 5 6 |
# File 'lib/callme/dep_metadata.rb', line 4 def factory_method @factory_method end |
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
4 5 6 |
# File 'lib/callme/dep_metadata.rb', line 4 def instance @instance end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/callme/dep_metadata.rb', line 4 def name @name end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
4 5 6 |
# File 'lib/callme/dep_metadata.rb', line 4 def scope @scope end |
Instance Method Details
#fetch_attrs!(klass) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/callme/dep_metadata.rb', line 35 def fetch_attrs!(klass) if klass.respond_to?(:_callme_injectable_attrs) klass._callme_injectable_attrs.each do |attr, | [:ref] ||= attr @attrs << Callme::DepMetadata::Attribute.new(attr, ) end end end |
#has_contract? ⇒ Boolean
48 49 50 |
# File 'lib/callme/dep_metadata.rb', line 48 def has_contract? !!@contract end |
#has_factory_method? ⇒ Boolean
44 45 46 |
# File 'lib/callme/dep_metadata.rb', line 44 def has_factory_method? !!@factory_method end |