diff options
author | Jose and Yehuda <wycats@gmail.com> | 2011-09-26 18:48:19 -0400 |
---|---|---|
committer | Jose and Yehuda <wycats@gmail.com> | 2011-10-15 18:40:37 +0200 |
commit | 8ff7693a8dc61f43fc4eaf72ed24d3b8699191fe (patch) | |
tree | 143183598cfaf683fd0629b195d85c5e1a5bee55 /actionpack/lib/action_controller | |
parent | 098c95abcb2b101bde0d55ddd5e348fda0ec8f49 (diff) | |
download | rails-8ff7693a8dc61f43fc4eaf72ed24d3b8699191fe.tar.gz rails-8ff7693a8dc61f43fc4eaf72ed24d3b8699191fe.tar.bz2 rails-8ff7693a8dc61f43fc4eaf72ed24d3b8699191fe.zip |
Initial commit of serializer support
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/base.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_controller/metal/serialization.rb | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 98bfe72fef..cfb9cf5e6e 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -190,6 +190,7 @@ module ActionController Redirecting, Rendering, Renderers::All, + Serialization, ConditionalGet, RackDelegation, SessionManagement, diff --git a/actionpack/lib/action_controller/metal/serialization.rb b/actionpack/lib/action_controller/metal/serialization.rb new file mode 100644 index 0000000000..9bb665a9ae --- /dev/null +++ b/actionpack/lib/action_controller/metal/serialization.rb @@ -0,0 +1,26 @@ +module ActionController + module Serialization + extend ActiveSupport::Concern + + include ActionController::Renderers + + included do + class_attribute :_serialization_scope + end + + def serialization_scope + send(_serialization_scope) + end + + def _render_option_json(json, options) + json = json.active_model_serializer.new(json, serialization_scope) if json.respond_to?(:active_model_serializer) + super + end + + module ClassMethods + def serialization_scope(scope) + self._serialization_scope = scope + end + end + end +end |