Sha256: 823f75b0434662ee31bd61ab11c8df996a37bbe39e1910bb775f04ebbc1aff5a

Contents?: true

Size: 1.59 KB

Versions: 9

Compression:

Stored size: 1.59 KB

Contents

# Copyright 2020 Pixar

#
#    Licensed under the Apache License, Version 2.0 (the "Apache License")
#    with the following modification; you may not use this file except in
#    compliance with the Apache License and the following modification to it:
#    Section 6. Trademarks. is deleted and replaced with:
#
#    6. Trademarks. This License does not grant permission to use the trade
#       names, trademarks, service marks, or product names of the Licensor
#       and its affiliates, except as required to comply with Section 4(c) of
#       the License and to reproduce the content of the NOTICE file.
#
#    You may obtain a copy of the Apache License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the Apache License with the above modification is
#    distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#    KIND, either express or implied. See the Apache License for the specific
#    language governing permissions and limitations under the Apache License.

# Gratefully borrowed from https://github.com/Invoca/ruby_dig

# modulize monkey patches
module RubyDig

  def dig(key, *rest)
    value = self[key]
    if value.nil? || rest.empty?
      value
    elsif value.respond_to?(:dig)
      value.dig(*rest)
    else
      raise TypeError, "#{value.class} does not have #dig method"
    end
  end

end

if RUBY_VERSION < '2.3'

  # arrays
  class Array; include RubyDig; end

  # hashes
  class Hash; include RubyDig; end

  # ostructs
  class OpenStruct; include RubyDig; end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ruby-jss-1.6.4 lib/jamf/ruby_extensions/dig.rb
ruby-jss-1.6.0 lib/jamf/ruby_extensions/dig.rb
ruby-jss-1.6.0b1 lib/jamf/ruby_extensions/dig.rb
ruby-jss-1.5.3 lib/jamf/ruby_extensions/dig.rb
ruby-jss-1.5.2 lib/jamf/ruby_extensions/dig.rb
ruby-jss-1.5.1 lib/jamf/ruby_extensions/dig.rb
ruby-jss-1.4.1 lib/jamf/ruby_extensions/dig.rb
ruby-jss-1.3.3 lib/jamf/ruby_extensions/dig.rb
ruby-jss-1.3.2 lib/jamf/ruby_extensions/dig.rb