Sha256: d9e4f47b80229fa1990eb7a056ac4007ab8a27e2f431db6d86a84c66d30eb8f8

Contents?: true

Size: 583 Bytes

Versions: 3

Compression:

Stored size: 583 Bytes

Contents

module Mongoo
  module Embedded
    class HashProxy

      def initialize(doc, hash, klass)
        @doc   = doc
        @hash  = hash
        @klass = klass
      end

      def build(hash)
        @klass.new(@doc,hash)
      end

      def raw
        @hash
      end

      def [](k)
        build raw[k]
      end

      def []=(k,o)
        raw[k] = o.to_hash
      end

      def each
        raw.each { |k,v| yield(k, build(v)) }
      end

      def size
        raw.size
      end

      def keys
        raw.keys
      end

    end # HashProxy
  end # Embedded
end # Mongoo

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongoo-0.4.8 lib/mongoo/embedded/hash_proxy.rb
mongoo-0.4.7 lib/mongoo/embedded/hash_proxy.rb
mongoo-0.4.6 lib/mongoo/embedded/hash_proxy.rb