Module: Omnibus::Sugarable

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



33
34
35
36
# File 'lib/omnibus/sugarable.rb', line 33

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

.included(base) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/omnibus/sugarable.rb', line 38

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

  if base < Cleanroom
    # Make all the "sugars" available in the cleanroom (DSL)
    Chef::Sugar::DSL.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.



59
60
61
# File 'lib/omnibus/sugarable.rb', line 59

def node
  Ohai
end