Sha256: 9368a111697cf50e36c5a62bd7a6b44633d5c79f96f12eedba3148e6c689a417

Contents?: true

Size: 412 Bytes

Versions: 9

Compression:

Stored size: 412 Bytes

Contents

module Runbook::Util
  class StickyHash < Hash
    def [](key)
      value = super
      value.is_a?(Glue) ? value.val : value
    end

    def []=(key, value)
      assoc = self.assoc(key)
      if assoc.nil? || ! assoc[1].is_a?(Glue)
        super
      else
        assoc[1].val = value
      end
    end
  end

  class Glue
    attr_accessor :val

    def initialize(val)
      @val = val
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
careacademy-runbook-1.2.0 lib/runbook/util/sticky_hash.rb
runbook-1.1.0 lib/runbook/util/sticky_hash.rb
runbook-1.0.0 lib/runbook/util/sticky_hash.rb
runbook-0.16.1 lib/runbook/util/sticky_hash.rb
runbook-0.16.0 lib/runbook/util/sticky_hash.rb
runbook-0.15.0 lib/runbook/util/sticky_hash.rb
runbook-0.14.0 lib/runbook/util/sticky_hash.rb
runbook-0.13.0 lib/runbook/util/sticky_hash.rb
runbook-0.12.1 lib/runbook/util/sticky_hash.rb