-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make serialize more similar to Rails, add YAML option
- Loading branch information
1 parent
2728ae6
commit 0de9f0e
Showing
3 changed files
with
63 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
module Neo4j::ActiveNode | ||
module SerializedProperties | ||
module SerializedProperties | ||
extend ActiveSupport::Concern | ||
|
||
def serialized_properties | ||
self.class.serialized_properties | ||
self.class.serialized_properties | ||
end | ||
|
||
module ClassMethods | ||
module ClassMethods | ||
|
||
def serialized_properties=(name) | ||
@serialize ||= [] | ||
@serialize.push name | ||
end | ||
def serialized_properties | ||
@serialize || {} | ||
end | ||
|
||
def serialized_properties | ||
@serialize || [] | ||
end | ||
|
||
def serialize(name) | ||
self.serialized_properties = name | ||
end | ||
end | ||
end | ||
end | ||
def serialize(name, coder = JSON) | ||
@serialize ||= {} | ||
@serialize[name] = coder | ||
end | ||
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
0de9f0e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://github.com/andreasronge/neo4j/wiki/Neo4j-v3#property-serialization
In short, it serializes as JSON by default; it uses YAML if you pass it the
Hash
constant. This is sort of the inverse of Rails, where YAML is the default and you pass JSON if you want to go that way.