Skip to content

Instantly share code, notes, and snippets.

@tyler-ball
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyler-ball/caccc555792a30332093 to your computer and use it in GitHub Desktop.
Save tyler-ball/caccc555792a30332093 to your computer and use it in GitHub Desktop.
Proposed module for defining to_json on Chef objects
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