Sha256: ff2c49540daafb9de9affed8fa22e1ffc9f91f7d95eeb8756c38fda584f8fbd9

Contents?: true

Size: 859 Bytes

Versions: 7

Compression:

Stored size: 859 Bytes

Contents

# frozen_string_literal: true

# simplest monkey patch, honest ;)
class Object
  # Only define blank? if it's not already defined
  unless method_defined?(:blank?)
    def blank?
      respond_to?(:empty?) ? empty? : !self
    end
  end
end

# At some point this will seem like a bad idea ;)

# :nocov:
if RUBY_VERSION < '2.5.0'
  class Hash
    # Non-mutating version (returns a new hash with transformed keys)
    def transform_keys
      return enum_for(:transform_keys) unless block_given?
      result = {}
      each_key do |key|
        result[yield(key)] = self[key]
      end
      result
    end

    # Mutating version (modifies the hash in place)
    def transform_keys!
      return enum_for(:transform_keys!) unless block_given?
      keys.each do |key|
        self[yield(key)] = delete(key)
      end
      self
    end
  end
end
# :nocov:end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruby_hubspot_api-0.3.3 lib/support/patches.rb
ruby_hubspot_api-0.3.2 lib/support/patches.rb
ruby_hubspot_api-0.3.1 lib/support/patches.rb
ruby_hubspot_api-0.3.0 lib/support/patches.rb
ruby_hubspot_api-0.2.2 lib/support/patches.rb
ruby_hubspot_api-0.2.1.1 lib/support/patches.rb
ruby_hubspot_api-0.2.1.pre.1 lib/support/patches.rb