Sha256: 748cdf914c4b5f217fdf73d6efe6afb31e8272ab0447c6cb82cf35d120ccc566

Contents?: true

Size: 390 Bytes

Versions: 5

Compression:

Stored size: 390 Bytes

Contents

module Encore
  module Serializer
    module Utils
      def self.fetch_serializer(model)
        default_serializer = (model.name.gsub('::', '') + 'Serializer')
        model.active_model_serializer || default_serializer.constantize
      rescue NameError
        raise NameError, "can’t find serializer for #{model.name}, try creating #{default_serializer}"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
encore-0.2.3 lib/encore/serializer/utils.rb
encore-0.2.2 lib/encore/serializer/utils.rb
encore-0.2.1 lib/encore/serializer/utils.rb
encore-0.2 lib/encore/serializer/utils.rb
encore-0.1 lib/encore/serializer/utils.rb