Sha256: cb319b540c42ddea39f3890c4ef3bc0720d0af3c6433f0f645675a62f0b63a30

Contents?: true

Size: 462 Bytes

Versions: 3

Compression:

Stored size: 462 Bytes

Contents

class Hash
  def open!
    class << self
      @_were_public = public_instance_methods - ['close!']
      @_were_public.each { |m| private m }
      def method_missing(s,*a)
        if s.to_s[-1,1] == '='
          self[s] = a.first
        else
          return self[s]
        end
      end
    end
  end
  def close!
    class << self
      @_were_public.each { |m| public m }
      @_were_public = nil
      remove_method(:method_missing)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
facets-1.8.20 work/hash_open.rb
facets-1.8.49 work/hash_open.rb
facets-1.8.8 work/hash_open.rb