class Mongoo::Embedded::HashProxy

Public Class Methods

new(doc, hash, klass) click to toggle source
# File lib/mongoo/embedded/hash_proxy.rb, line 5
def initialize(doc, hash, klass)
  @doc   = doc
  @hash  = hash
  @klass = klass
end

Public Instance Methods

[](k) click to toggle source
# File lib/mongoo/embedded/hash_proxy.rb, line 20
def [](k)
  build raw[k], k
end
[]=(k,o) click to toggle source
# File lib/mongoo/embedded/hash_proxy.rb, line 28
def []=(k,o)
  raw[k] = o.to_hash
end
all() click to toggle source
# File lib/mongoo/embedded/hash_proxy.rb, line 52
def all
  keys.collect { |k| self[k] }
end
build(hash, k=nil) click to toggle source
# File lib/mongoo/embedded/hash_proxy.rb, line 11
def build(hash, k=nil)
  return nil if hash.nil?
  @klass.new(@doc, hash, k)
end
delete(k) click to toggle source
# File lib/mongoo/embedded/hash_proxy.rb, line 24
def delete(k)
  raw.delete(k)
end
each() { |k, build(v, k)| ... } click to toggle source
# File lib/mongoo/embedded/hash_proxy.rb, line 32
def each
  raw.each { |k,v| yield(k, build(v, k)) }
end
first() click to toggle source
# File lib/mongoo/embedded/hash_proxy.rb, line 44
def first
  self[keys.first]
end
keys() click to toggle source
# File lib/mongoo/embedded/hash_proxy.rb, line 40
def keys
  raw.keys
end
last() click to toggle source
# File lib/mongoo/embedded/hash_proxy.rb, line 48
def last
  self[keys.last]
end
push(obj) click to toggle source
# File lib/mongoo/embedded/hash_proxy.rb, line 56
def push(obj)
  k = BSON::ObjectId.new.to_s
  self[k] = obj; k
end
raw() click to toggle source
# File lib/mongoo/embedded/hash_proxy.rb, line 16
def raw
  @hash
end
size() click to toggle source
# File lib/mongoo/embedded/hash_proxy.rb, line 36
def size
  raw.size
end