Class: Rackful::Serializer Abstract
- Inherits:
-
Object
- Object
- Rackful::Serializer
- Includes:
- Enumerable
- Defined in:
- lib/rackful/serializer.rb
Overview
This class is abstract.
Subclasses must implement method #each
end define constant
CONTENT_TYPES
Base class for all serializers.
The serializers XHTML and JSON defined in this library depend on the presence of method resource.to_rackful.
Defined Under Namespace
Instance Attribute Summary (collapse)
-
- (String) content_type
readonly
The content type to be served by this Serializer.
- - (Request) request readonly
- - (Resource) resource readonly
Instance Method Summary (collapse)
- - (void) each {|block| ... } abstract
-
- (Hash) headers
abstract
Extra response headers that a serializer likes to return.
-
- (Serializer) initialize(request, resource, content_type)
constructor
A new instance of Serializer.
Constructor Details
- (Serializer) initialize(request, resource, content_type)
Returns a new instance of Serializer
34 35 36 37 |
# File 'lib/rackful/serializer.rb', line 34 def initialize request, resource, content_type @request, @resource, @content_type = request, resource, content_type end |
Instance Attribute Details
- (String) content_type (readonly)
Returns The content type to be served by this Serializer. This will always
be one of the content types listed in constant CONTENT_TYPES
.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rackful/serializer.rb', line 22 class Serializer include Enumerable attr_reader :request, :resource, :content_type # @param request [Request] # @param resource [Resource] # @param content_type [String] def initialize request, resource, content_type @request, @resource, @content_type = request, resource, content_type end # @!method headers() # Extra response headers that a serializer likes to return. # # You don't have to include the `Content-Type` header, as this is done # _for_ you. # # This method is optional. # @return [Hash] # @abstract # @abstract Every serializer must implement this method. # @yieldparam block [String] (part of) the entity body def each raise NotImplementedError end end |
- (Request) request (readonly)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rackful/serializer.rb', line 22 class Serializer include Enumerable attr_reader :request, :resource, :content_type # @param request [Request] # @param resource [Resource] # @param content_type [String] def initialize request, resource, content_type @request, @resource, @content_type = request, resource, content_type end # @!method headers() # Extra response headers that a serializer likes to return. # # You don't have to include the `Content-Type` header, as this is done # _for_ you. # # This method is optional. # @return [Hash] # @abstract # @abstract Every serializer must implement this method. # @yieldparam block [String] (part of) the entity body def each raise NotImplementedError end end |
- (Resource) resource (readonly)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rackful/serializer.rb', line 22 class Serializer include Enumerable attr_reader :request, :resource, :content_type # @param request [Request] # @param resource [Resource] # @param content_type [String] def initialize request, resource, content_type @request, @resource, @content_type = request, resource, content_type end # @!method headers() # Extra response headers that a serializer likes to return. # # You don't have to include the `Content-Type` header, as this is done # _for_ you. # # This method is optional. # @return [Hash] # @abstract # @abstract Every serializer must implement this method. # @yieldparam block [String] (part of) the entity body def each raise NotImplementedError end end |
Instance Method Details
- (void) each {|block| ... }
This method is abstract.
Every serializer must implement this method.
53 54 55 |
# File 'lib/rackful/serializer.rb', line 53 def each raise NotImplementedError end |
- (Hash) headers
This method is abstract.
Extra response headers that a serializer likes to return.
You don't have to include the Content-Type
header, as this is
done for you.
This method is optional.
|
# File 'lib/rackful/serializer.rb', line 40
|