Module: Salt::Formula
- Defined in:
- lib/salt/formula.rb
Defined Under Namespace
Class Method Summary collapse
-
.new(name, basedir, args) ⇒ Object < R10K::Module] A member of the implementing subclass
Look up the implementing class and instantiate an object.
-
.register(klass) ⇒ Object
Register an module implementation for later generation.
Class Method Details
.new(name, basedir, 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.
24 25 26 27 28 29 30 31 |
# File 'lib/salt/formula.rb', line 24 def self.new(name, basedir, args) if implementation = @klasses.find { |klass| klass.implement?(name, args) } obj = implementation.new(name, basedir, args) obj else raise "Module #{name} with args #{args.inspect} doesn't have an implementation. (Are you using the right arguments?)" end end |
.register(klass) ⇒ Object
Register an module implementation for later generation
7 8 9 10 |
# File 'lib/salt/formula.rb', line 7 def self.register(klass) @klasses ||= [] @klasses << klass end |