Class: R10K::Module
- Inherits:
-
Object
- Object
- R10K::Module
- Defined in:
- lib/r10k/module.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
-
.inherited(klass) ⇒ Object
Register an inheriting class for later generation.
-
.new(name, path, args) ⇒ Object < R10K::Module] A member of the implementing subclass
Look up the implementing class and instantiate an object.
Instance Method Summary collapse
- #full_path ⇒ Object
-
#initialize(name, path, args) ⇒ Module
constructor
A new instance of Module.
Constructor Details
#initialize(name, path, args) ⇒ Module
Returns a new instance of Module.
35 36 37 |
# File 'lib/r10k/module.rb', line 35 def initialize(name, path, args) @name, @path, @args = name, path, args end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
33 34 35 |
# File 'lib/r10k/module.rb', line 33 def name @name end |
#path ⇒ Object
Returns the value of attribute path.
33 34 35 |
# File 'lib/r10k/module.rb', line 33 def path @path end |
Class Method Details
.inherited(klass) ⇒ Object
Register an inheriting class for later generation
6 7 8 9 |
# File 'lib/r10k/module.rb', line 6 def self.inherited(klass) @klasses ||= [] @klasses << klass end |
.new(name, path, args) ⇒ Object < R10K::Module] A member of the implementing subclass
Look up the implementing class and instantiate an object
This method takes the arguments for normal object generation and checks all inheriting classes to see if they implement the behavior needed to create the requested object. It selects the first class that can implement an object with ‘name, args`, and generates an object of that class.
23 24 25 26 27 28 29 30 31 |
# File 'lib/r10k/module.rb', line 23 def self.new(name, path, args) if implementation = @klasses.find { |klass| klass.implements(name, args) } obj = implementation.send(:allocate) obj.send(:initialize, name, path, args) obj else raise "Module #{name} with args #{args.inspect} doesn't have an implementation. (Are you using the right arguments?)" end end |
Instance Method Details
#full_path ⇒ Object
39 40 41 |
# File 'lib/r10k/module.rb', line 39 def full_path File.join(@path, @name) end |