Sha256: d8717080415dba97f3254d55fe3130fb868378921e580ca7fe292d651a543b51
Contents?: true
Size: 741 Bytes
Versions: 3
Compression:
Stored size: 741 Bytes
Contents
require 'alba/version' require 'alba/serializers/default_serializer' require 'alba/serializer' require 'alba/resource' require 'alba/resources/default_resource' # Core module 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 def resource_class ::Alba::Resources::DefaultResource.clone end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
alba-0.8.0 | lib/alba.rb |
alba-0.7.0 | lib/alba.rb |
alba-0.6.0 | lib/alba.rb |