Module: ActionController::Serialization
- Extended by:
- ActiveSupport::Concern
- Includes:
- Renderers
- Defined in:
- lib/action_controller/serialization.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #get_serializer(resource, options = {}) ⇒ Object
- #namespace_for_serializer ⇒ Object
- #serialization_scope ⇒ Object
-
#use_adapter? ⇒ Boolean
Deprecated.
Instance Method Details
#get_serializer(resource, options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/action_controller/serialization.rb', line 33 def get_serializer(resource, = {}) unless use_adapter? warn 'ActionController::Serialization#use_adapter? has been removed. '\ "Please pass 'adapter: false' or see ActiveSupport::SerializableResource.new" [:adapter] = false end .fetch(:namespace) { [:namespace] = namespace_for_serializer } serializable_resource = ActiveModelSerializers::SerializableResource.new(resource, ) serializable_resource.serialization_scope ||= .fetch(:scope) { serialization_scope } serializable_resource.serialization_scope_name = .fetch(:scope_name) { _serialization_scope } # For compatibility with the JSON renderer: `json.to_json(options) if json.is_a?(String)`. # Otherwise, since `serializable_resource` is not a string, the renderer would call # `to_json` on a String and given odd results, such as `"".to_json #=> '""'` serializable_resource.adapter.is_a?(String) ? serializable_resource.adapter : serializable_resource end |
#namespace_for_serializer ⇒ Object
23 24 25 |
# File 'lib/action_controller/serialization.rb', line 23 def namespace_for_serializer @namespace_for_serializer ||= self.class.parent unless self.class.parent == Object end |
#serialization_scope ⇒ Object
27 28 29 30 31 |
# File 'lib/action_controller/serialization.rb', line 27 def serialization_scope return unless _serialization_scope && respond_to?(_serialization_scope, true) send(_serialization_scope) end |
#use_adapter? ⇒ Boolean
Deprecated
52 53 54 |
# File 'lib/action_controller/serialization.rb', line 52 def use_adapter? true end |