Class: Deptree::Definition

Inherits:
BasicObject
Defined in:
lib/deptree/definition.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dependency) ⇒ Definition

Returns a new instance of Definition.



14
15
16
# File 'lib/deptree/definition.rb', line 14

def initialize(dependency)
  @dependency = dependency
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, &behaviour) ⇒ Object



18
19
20
# File 'lib/deptree/definition.rb', line 18

def method_missing(name, &behaviour)
  @dependency.action(name, &behaviour)
end

Class Method Details

.add(configurable, args, block) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/deptree/definition.rb', line 4

def self.add(configurable, args, block)
  parser = ArgumentsParser.new(args).parse!
  prerequisites = Dependency::PrerequisitesProxy.new(parser.prerequisites, configurable.registry)
  name = parser.name

  dependency = Dependency.new(name, prerequisites, configurable.helpers)
  new(dependency).instance_eval(&block)
  configurable.registry.add(dependency.name, dependency)
end