Sha256: ee81b0b03f70e618d4d5b970c2e1fcaf8f83aafe63324ddaec457fe4c31aff5e
Contents?: true
Size: 864 Bytes
Versions: 19
Compression:
Stored size: 864 Bytes
Contents
module Pliny::Helpers module Serialize def self.included(base) base.send :extend, ClassMethods end def serialize(data, structure = :default) if self.class.serializer_class.nil? raise <<-eos.strip No serializer has been specified for this endpoint. Please specify one with `serializer Serializers::ModelName` in the endpoint. eos end self.class.serializer_class.new(structure).serialize(data) end module ClassMethods # Provide a way to specify endpoint serializer class. # # class Endpoints::User < Base # serializer Serializers::User # # get do # encode serialize(User.all) # end # end def serializer(serializer_class) @serializer_class = serializer_class end attr_reader :serializer_class end end end
Version data entries
19 entries across 19 versions & 1 rubygems