Last active
August 29, 2015 14:06
-
-
Save tyler-ball/caccc555792a30332093 to your computer and use it in GitHub Desktop.
Proposed module for defining to_json on Chef objects
This file contains hidden or 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
module Chef::JSONable | |
# Serialize this object as a hash | |
def to_json(*a) | |
Chef::JSONCompat.to_json(for_json, *a) | |
end | |
def for_json | |
raise "You must define `for_json` in your JSONable class" | |
# Alternatively, return self? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment