lib/alba.rb in alba-0.5.0 vs lib/alba.rb in alba-0.6.0
- old
+ new
@@ -8,19 +8,21 @@
module Alba
class Error < StandardError; end
class << self
attr_reader :backend
+ attr_accessor :default_serializer
def backend=(backend)
@backend = backend&.to_sym
end
def serialize(object, with: nil, &block)
raise ArgumentError, 'Block required' unless block
resource_class.class_eval(&block)
resource = resource_class.new(object)
+ with ||= @default_serializer
resource.serialize(with: with)
end
private