Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: David A. Cuadrado <krawek@gmail.com>
- Loading branch information
Showing
4 changed files
with
15 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
require 'ostruct' | ||
|
||
class OpenStruct | ||
include Mongoid::Fields::Serializable | ||
module MongoidExt | ||
class OpenStruct < ::OpenStruct | ||
include Mongoid::Fields::Serializable | ||
|
||
def serialize(value) | ||
value.nil? ? nil : value.to_hash | ||
end | ||
def serialize(value) | ||
value.nil? ? nil : value.to_hash | ||
end | ||
|
||
def deserialize(value) | ||
value.nil? ? nil : OpenStruct.new(value || {}) | ||
end | ||
def deserialize(value) | ||
value.nil? ? nil : OpenStruct.new(value || {}) | ||
end | ||
|
||
def to_hash | ||
send(:table) | ||
def to_hash | ||
send(:table) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters