@@ -3,6 +3,8 @@ module ActiveModel
3
3
class SerializableResource
4
4
ADAPTER_OPTION_KEYS = Set . new ( [ :include , :fields , :adapter ] )
5
5
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.
6
8
def initialize ( resource , options = { } )
7
9
@resource = resource
8
10
@adapter_opts , @serializer_opts =
@@ -11,20 +13,6 @@ def initialize(resource, options = {})
11
13
12
14
delegate :serializable_hash , :as_json , :to_json , to : :adapter
13
15
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
-
28
16
def serialization_scope = ( scope )
29
17
serializer_opts [ :scope ] = scope
30
18
end
0 commit comments