lib/alba.rb in alba-0.3.0 vs lib/alba.rb in alba-0.4.0

- old
+ new

@@ -1,8 +1,9 @@ require 'alba/version' +require 'alba/serializers/default_serializer' +require 'alba/serializer' require 'alba/resource' -require 'json' # Core module module Alba class Error < StandardError; end @@ -13,19 +14,8 @@ def self.backend=(backend) @backend = backend&.to_sym end def self.serialize(object) - fallback = ->(resource) { resource.to_json } - case backend - when :oj - begin - require 'oj' - ->(resource) { Oj.dump(resource) } - rescue LoadError - fallback - end - else - fallback - end.call(object) + Serializers::DefaultSerializer.new(object).serialize end end