Last active
December 13, 2015 18:08
-
-
Save mnin/4952990 to your computer and use it in GitHub Desktop.
monkey patch to pass some options (e.g. create :create_additions for couch_potato) to the json adapter
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
# config/initializers/multi_json.rb | |
+ MultiJson.default_options = { create_additions: true } | |
# lib/gem_ext/multi_json/multi_json.rb | |
module MultiJson | |
# Decode a JSON string into Ruby. | |
# | |
# <b>Options</b> | |
# | |
# <tt>:symbolize_keys</tt> :: If true, will use symbols instead of strings for the keys. | |
# <tt>:adapter</tt> :: If set, the selected engine will be used just for the call. | |
def load(string, options={}) | |
+ options = default_options.merge(options) | |
adapter = current_adapter(options) | |
begin | |
adapter.load(string, options) | |
rescue adapter::ParseError => exception | |
raise LoadError.new(exception.message, exception.backtrace, string) | |
end | |
end | |
# :nodoc: | |
alias :decode :load | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
But wouldn't this always enable create_additions, also for requests that come from untrusted web clients?