Class: Orchestra::DSL::NodeFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/orchestra/dsl/object_adapter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter, args = {}) ⇒ NodeFactory

Returns a new instance of NodeFactory.



97
98
99
100
101
# File 'lib/orchestra/dsl/object_adapter.rb', line 97

def initialize adapter, args = {}
  @adapter = adapter
  @provides, @compact, @thread_count = Util.extract_key_args args,
    :provides => nil, :compact => false, :thread_count => nil
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



95
96
97
# File 'lib/orchestra/dsl/object_adapter.rb', line 95

def adapter
  @adapter
end

#compactObject (readonly)

Returns the value of attribute compact.



95
96
97
# File 'lib/orchestra/dsl/object_adapter.rb', line 95

def compact
  @compact
end

#providesObject (readonly)

Returns the value of attribute provides.



95
96
97
# File 'lib/orchestra/dsl/object_adapter.rb', line 95

def provides
  @provides
end

#thread_countObject (readonly)

Returns the value of attribute thread_count.



95
96
97
# File 'lib/orchestra/dsl/object_adapter.rb', line 95

def thread_count
  @thread_count
end

Class Method Details

.build(*args) ⇒ Object



90
91
92
93
# File 'lib/orchestra/dsl/object_adapter.rb', line 90

def self.build *args
  instance = new *args
  instance.build_node
end

Instance Method Details

#build_nodeObject



103
104
105
106
# File 'lib/orchestra/dsl/object_adapter.rb', line 103

def build_node
  adapter.validate!
  Node::DelegateNode.new adapter, build_node_args
end

#build_node_argsObject



108
109
110
111
112
113
114
115
# File 'lib/orchestra/dsl/object_adapter.rb', line 108

def build_node_args
  hsh = {
    :dependencies => adapter.dependencies,
    :provides     => Array(provides),
  }
  hsh[:collection] = adapter.collection if adapter.collection?
  hsh
end