Skip to content

Commit 74c9df7

Browse files
committed
two option serializer
1 parent ffadceb commit 74c9df7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/ruby_json_api_client/store.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ def self.register_adapter(name, klass = nil, options = {})
1818
def self.register_serializer(name, klass = nil, options = {})
1919
@serializers ||= {}
2020

21-
if klass.nil?
21+
# allow for 2 arguments (automatically figure out class if so)
22+
if !klass.is_a?(Class)
23+
# klass is options. autoamtically figure out klass and set options
24+
temp = klass || options
2225
class_name = name.to_s.camelize
2326
klass = Kernel.const_get("RubyJsonApiClient::#{class_name}Serializer")
27+
options = temp
2428
end
2529

2630
@serializers[name] = OpenStruct.new({ klass: klass, options: options })

0 commit comments

Comments
 (0)