Sha256: 3b53a62ed51208256e2343d73f48f600bb98b9b95e84603f18e590e161ef6fc8

Contents?: true

Size: 550 Bytes

Versions: 23

Compression:

Stored size: 550 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)
    normalised_identifier = identifier.to_s.downcase
    [normalised_identifier, normalised_identifier.singularize].each do |format|
      klass = RestPack::Serializer.class_map[format]
      return klass.new if klass
    end

    raise "Invalid RestPack::Serializer : #{identifier}"
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
restpack_serializer-0.4.26 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.25 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.24 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.23 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.21 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.20 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.19 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.18 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.17 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.16 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.15 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.14 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.13 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.12 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.11 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.10 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.9 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.8 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.7 lib/restpack_serializer/factory.rb
restpack_serializer-0.4.6 lib/restpack_serializer/factory.rb