We have a NodeHelpers module and extend the Chef::Node object with it.
module NodeHelpers
def envparser
chef_gem_install('environment-parser', node['parsers']['environment_parser']['version'])
require 'environment/parser'
EnvironmentParser.new(node.chef_environment)
end
def phase
envparser.phase
end
end
class Chef
class Node
include NodeHelpers
end
end
Try to use the phase method:
FoodCritic returns the follow lint warning presumably because it doesn't know about the helper libraries and how Chef::Node is being extended. Any way to get FC to know about the added methods and not complain here? (edit: formatting)
FC019: Access node attributes in a consistent manner
We have a
NodeHelpers
module and extend the Chef::Node object with it.phase
method:FoodCritic returns the follow lint warning presumably because it doesn't know about the helper libraries and how Chef::Node is being extended. Any way to get FC to know about the added methods and not complain here? (edit: formatting)
FC019: Access node attributes in a consistent manner