@@ -3,6 +3,8 @@ module ActiveModel
33 class SerializableResource
44 ADAPTER_OPTION_KEYS = Set . new ( [ :include , :fields , :adapter ] )
55
6+ # Primary interface to composing a resource with a serializer and adapter.
7+ # @return the serializable_resource, ready for #as_json/#to_json/#serializable_hash.
68 def initialize ( resource , options = { } )
79 @resource = resource
810 @adapter_opts , @serializer_opts =
@@ -11,20 +13,6 @@ def initialize(resource, options = {})
1113
1214 delegate :serializable_hash , :as_json , :to_json , to : :adapter
1315
14- # Primary interface to building a serializer (with adapter)
15- # If no block is given,
16- # returns the serializable_resource, ready for #as_json/#to_json/#serializable_hash.
17- # Otherwise, yields the serializable_resource and
18- # returns the contents of the block
19- def self . serialize ( resource , options = { } )
20- serializable_resource = SerializableResource . new ( resource , options )
21- if block_given?
22- yield serializable_resource
23- else
24- serializable_resource
25- end
26- end
27-
2816 def serialization_scope = ( scope )
2917 serializer_opts [ :scope ] = scope
3018 end
0 commit comments