Module: Ironfan::Plugin::Base

Extended by:
Gorillib::Concern
Included in:
Dsl::Cluster, Dsl::Component, Dsl::Facet
Defined in:
lib/ironfan/headers.rb,
lib/ironfan/plugin/base.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#to_nodeObject


37
38
39
40
41
42
43
44
45
46
# File 'lib/ironfan/plugin/base.rb', line 37

def to_node
  Chef::Node.new.tap do |node|
    self.class.fields.select{|_,x| x.node_attr}.each do |_,x|
      val = send(x.name)
      (keys = x.node_attr.split('.'))[0...-1].inject(node.set) do |hsh,key|
        hsh[key]
      end[keys.last] = val unless val.nil?
    end
  end
end