Class: Rackful::Serializer Abstract

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
gems/rackful-0.1.1/lib/rackful_serializer.rb,
gems/rackful-0.1.1.orig/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 default serializers defined in this library (XHTML and JSON) depend on the availability of method Resource#to_rackful.

Since:

Direct Known Subclasses

EPIC::TXT, JSON, XHTML

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Serializer) initialize(resource, content_type)

A new instance of Serializer

Since:

  • 0.1.0



31
32
33
# File 'gems/rackful-0.1.1/lib/rackful_serializer.rb', line 31

def initialize resource, content_type
  @resource, @content_type = resource, content_type
end

Instance Attribute Details

- (void) content_type (readonly)

Since:

  • 0.1.0



28
29
30
# File 'gems/rackful-0.1.1/lib/rackful_serializer.rb', line 28

def content_type
  @content_type
end

- (void) resource (readonly)

Since:

  • 0.1.0



28
29
30
# File 'gems/rackful-0.1.1/lib/rackful_serializer.rb', line 28

def resource
  @resource
end

Instance Method Details

- (void) each

This method is abstract.

Every serializer must implement this method.

Raises:

  • (HTTP500InternalServerError)

Since:

  • 0.1.0



41
42
43
# File 'gems/rackful-0.1.1/lib/rackful_serializer.rb', line 41

def each
  raise HTTP500InternalServerError, "Class #{self.class} doesn't implement #each()."
end