Class: MongoModel::Types::OpenStruct

Inherits:
Object
  • Object
show all
Defined in:
lib/mongomodel/support/types/openstruct.rb

Instance Method Summary collapse

Methods inherited from Object

#boolean, #to_query

Instance Method Details

#cast(value) ⇒ Object


6
7
8
9
10
11
12
13
# File 'lib/mongomodel/support/types/openstruct.rb', line 6

def cast(value)
  case value
  when ::OpenStruct
    value
  else
    ::OpenStruct.new(value)
  end
end

#from_mongo(value) ⇒ Object


19
20
21
# File 'lib/mongomodel/support/types/openstruct.rb', line 19

def from_mongo(value)
  ::OpenStruct.new(value)
end

#to_mongo(value) ⇒ Object


15
16
17
# File 'lib/mongomodel/support/types/openstruct.rb', line 15

def to_mongo(value)
  value.marshal_dump if value
end