Module: Uorm::Mongo

Defined in:
lib/uorm/mongo.rb,
lib/uorm/mongo/persistance.rb

Defined Under Namespace

Classes: Persistance

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/uorm/mongo.rb', line 10

def self.included base
  base.instance_eval do
    field :id, type: :ObjectId
  end

  def initialize values = {}
    values[:id] ||= values.delete('_id') || values.delete(:_id)
    super values
  end
end

Instance Method Details

#initialize(values = {}) ⇒ Object



15
16
17
18
# File 'lib/uorm/mongo.rb', line 15

def initialize values = {}
  values[:id] ||= values.delete('_id') || values.delete(:_id)
  super values
end