Module: Omnibus::Sugarable

Included in:
Config, HealthCheck, Licensing, Metadata, Metadata, Packager, Packager::Base, Project, Software
Defined in:
lib/omnibus/sugarable.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



21
22
23
24
# File 'lib/omnibus/sugarable.rb', line 21

def self.extended(base)
  base.send(:extend, ChefUtils)
  base.send(:extend, Omnibus::Sugar)
end

.included(base) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/omnibus/sugarable.rb', line 26

def self.included(base)
  base.send(:include, ChefUtils)
  base.send(:include, Omnibus::Sugar)

  if base < Cleanroom
    # Make all the "sugars" available in the cleanroom (DSL)
    ChefUtils.instance_methods.each do |instance_method|
      base.send(:expose, instance_method)
    end

    # Make all the common "sugars" available in the cleanroom (DSL)
    Omnibus::Sugar.instance_methods.each do |instance_method|
      base.send(:expose, instance_method)
    end
  end
end

Instance Method Details

#nodeObject

This method is used by Chef Sugar to easily add the DSL. By mimicing Chef’s node object, we can easily include the existing DSL into Omnibus project as if it were Chef. Otherwise, we would need to rewrite all the DSL methods.



47
48
49
# File 'lib/omnibus/sugarable.rb', line 47

def node
  Ohai
end