Class: Packerman::Dsl

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

Direct Known Subclasses

Builders, HashObject, Provisioners, Variables

Defined Under Namespace

Modules: Node Classes: Builders, HashObject, Provisioners, Variables

Class Method Summary collapse

Class Method Details

.register(type: "", &block) ⇒ Object



3
4
5
6
7
# File 'lib/packerman/dsl.rb', line 3

def register(type: "", &block)
  product = to_subclass(type).new
  product.instance_eval(&block)
  register_to_repo(product.to_hash)
end

.register_to_repo(product) ⇒ Object



9
10
11
# File 'lib/packerman/dsl.rb', line 9

def register_to_repo(product)
  Packerman::Repository.instance.send("add_#{name.demodulize.underscore}", product)
end

.to_subclass(type) ⇒ Object



13
14
15
# File 'lib/packerman/dsl.rb', line 13

def to_subclass(type)
  "#{name}/#{type}".underscore.camelize.constantize
end