Revert to old MultiJson syntax.
This commit is contained in:
parent
28f3dbedd0
commit
360d70b838
@ -1,7 +1,10 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 0.1.4 (Unreleased)
|
||||
* Use MultiJson's preferred JSON engine as default
|
||||
|
||||
## 0.1.3
|
||||
* Render correcly when variables are not passed via the assigns ivar but as helper methods
|
||||
* Render correctly when variables are not passed via the assigns ivar but as helper methods
|
||||
(decent_exposure, focused_controller)
|
||||
* Add custom Responder
|
||||
|
||||
@ -13,7 +16,7 @@
|
||||
## 0.1.1
|
||||
|
||||
* Add CHANGELOG
|
||||
* Remove unnused test in loop
|
||||
* Remove unused test in loop
|
||||
* Speed up rendering by not double copying variable from context
|
||||
* Rename private variable to avoid name conflict
|
||||
* Remove sqlite3 development dependency
|
@ -26,8 +26,6 @@ module RablRails
|
||||
mattr_accessor :include_json_root
|
||||
@@include_json_root = true
|
||||
|
||||
mattr_reader :json_engine
|
||||
|
||||
mattr_accessor :use_custom_responder
|
||||
@@use_custom_responder = false
|
||||
|
||||
@ -41,10 +39,13 @@ module RablRails
|
||||
end
|
||||
|
||||
def self.json_engine=(name)
|
||||
MultiJson.respond_to?(:use) ? MultiJson.use(name) : MultiJson.engine = name
|
||||
@@json_engine = name
|
||||
MultiJson.engine = name
|
||||
rescue LoadError
|
||||
Rails.logger.warn %Q(WARNING: rabl-rails could not load "#{self.json_engine}" as JSON engine, fallback to default)
|
||||
Rails.logger.warn %Q(WARNING: rabl-rails could not load "#{name}" as JSON engine, fallback to default)
|
||||
end
|
||||
|
||||
def self.json_engine
|
||||
MultiJson.engine
|
||||
end
|
||||
|
||||
def self.cache_templates?
|
||||
@ -52,6 +53,6 @@ module RablRails
|
||||
end
|
||||
|
||||
def self.load_default_engines!
|
||||
self.json_engine = MultiJson.respond_to?(default_adapter) ? MultiJson.default_adapter : MultiJson.default_engine
|
||||
self.json_engine = MultiJson.default_engine
|
||||
end
|
||||
end
|
||||
|
@ -3,7 +3,7 @@ module RablRails
|
||||
class JSON < Base
|
||||
def format_output(hash)
|
||||
hash = { _options[:root_name] => hash } if _options[:root_name] && RablRails.include_json_root
|
||||
MultiJson.respond_to?(:dump) ? MultiJson.dump(hash) : MultiJson.encode(hash)
|
||||
MultiJson.encode(hash)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user