Sha256: 1ad6aeb02704c140e69bb2e17711d47079f76e824dbb314f09f196e7c5911ad1

Contents?: true

Size: 509 Bytes

Versions: 21

Compression:

Stored size: 509 Bytes

Contents

# frozen_string_literal: true

module Isolator
  # Hash with key accessors
  class SimpleHashie < Hash
    def method_missing(key, *args, &block)
      key_str = key.to_s

      if key_str.end_with?("=")
        self[key_str.tr("=")] = args.first
      else
        fetch(key_str) { super }
      end
    end

    def respond_to_missing?(key)
      key_str = key.to_s
      if key_str.end_with?("=")
        key?(key_str.tr("=")) || super
      else
        key?(key_str) || super
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
isolator-1.1.0 lib/isolator/simple_hashie.rb
isolator-1.0.1 lib/isolator/simple_hashie.rb
isolator-1.0.0 lib/isolator/simple_hashie.rb
isolator-0.11.0 lib/isolator/simple_hashie.rb
isolator-0.10.0 lib/isolator/simple_hashie.rb
isolator-0.9.0 lib/isolator/simple_hashie.rb
isolator-0.8.0 lib/isolator/simple_hashie.rb
isolator-0.7.0 lib/isolator/simple_hashie.rb
isolator-0.6.2 lib/isolator/simple_hashie.rb
isolator-0.6.1 lib/isolator/simple_hashie.rb
isolator-0.6.0 lib/isolator/simple_hashie.rb
isolator-0.5.0 lib/isolator/simple_hashie.rb
isolator-0.4.0 lib/isolator/simple_hashie.rb
isolator-0.3.0 lib/isolator/simple_hashie.rb
isolator-0.2.2 lib/isolator/simple_hashie.rb
isolator-0.2.1 lib/isolator/simple_hashie.rb
isolator-0.2.0 lib/isolator/simple_hashie.rb
isolator-0.1.1 lib/isolator/simple_hashie.rb
isolator-0.1.0 lib/isolator/simple_hashie.rb
isolator-0.1.0.pre2 lib/isolator/simple_hashie.rb