Sha256: 111194036b0a3cf3a2f02b5acc4bba94c1ed6d1d4f7a20a8d46b2bb9d49c5f78

Contents?: true

Size: 433 Bytes

Versions: 16

Compression:

Stored size: 433 Bytes

Contents

class RestPack::Serializer::Factory
  def self.create(*identifiers)
    serializers = identifiers.map { |identifier| self.classify(identifier) }
    serializers.count == 1 ? serializers.first : serializers
  end

  private

  def self.classify(identifier)
    begin
      "#{identifier}Serializer".classify.constantize.new
    rescue
      "#{identifier.to_s.singularize.to_sym}Serializer".classify.constantize.new
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
restpack_serializer-0.4.2 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.1 lib/restpack_serializer/factory.rb
restpack_serializer-0.2.16 lib/restpack_serializer/factory.rb
restpack_serializer-0.2.15 lib/restpack_serializer/factory.rb
restpack_serializer-0.2.14 lib/restpack_serializer/factory.rb
restpack_serializer-0.2.13 lib/restpack_serializer/factory.rb
restpack_serializer-0.2.12 lib/restpack_serializer/factory.rb
restpack_serializer-0.2.11 lib/restpack_serializer/factory.rb
restpack_serializer-0.2.10 lib/restpack_serializer/factory.rb
restpack_serializer-0.2.9 lib/restpack_serializer/factory.rb
restpack_serializer-0.2.8 lib/restpack_serializer/factory.rb
restpack_serializer-0.2.7 lib/restpack_serializer/factory.rb
restpack_serializer-0.2.6 lib/restpack_serializer/factory.rb
restpack_serializer-0.2.5 lib/restpack_serializer/factory.rb
restpack_serializer-0.2.4 lib/restpack_serializer/factory.rb
restpack_serializer-0.2.3 lib/restpack_serializer/factory.rb