lib/chef/sugar/node.rb in chef-sugar-ng-5.0.4 vs lib/chef/sugar/node.rb in chef-sugar-ng-5.1.8

- old
+ new

@@ -12,10 +12,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # +require_relative "deprecation" + class Chef class Node class AttributeDoesNotExistError < StandardError def initialize(keys, key) hash = keys.map { |key| "['#{key}']" } @@ -34,10 +36,11 @@ # @param [String, Regex] environment # # @return [Boolean] # def in?(environment) + Chef::Sugar::Deprecation.deprecated "the chef-sugar node.in? method is deprecated" environment === chef_environment end # # Safely fetch a deeply nested attribute by specifying a list of keys, @@ -47,10 +50,11 @@ # This method will return +nil+ if any deeply nested key does not exist. # # @see [Node#deep_fetch!] # def deep_fetch(*keys) + Chef::Sugar::Deprecation.deprecated "the chef-sugar deep_fetch method is deprecated and should be replaced by node.read" deep_fetch!(*keys) rescue NoMethodError, AttributeDoesNotExistError nil end @@ -69,10 +73,11 @@ # the list of keys to kdeep fetch # # @return [Object] # def deep_fetch!(*keys) + Chef::Sugar::Deprecation.deprecated "the chef-sugar deep_fetch method is deprecated and should be replaced by node.read!" keys.map!(&:to_s) keys.inject(attributes.to_hash) do |hash, key| if hash.key?(key) hash[key] @@ -131,9 +136,10 @@ # # @return [nil] # to prevent accidential method chaining if the block isn't closed # def namespace(*args, &block) + Chef::Sugar::Deprecation.deprecated "the chef-sugar attribute namespace setting is deprecated, please use traditional chef attribute notation" @namespace_options = namespace_options.merge(args.last.is_a?(Hash) ? args.pop : {}) keys = args.map(&:to_s) @current_namespace = current_namespace + keys