Class: DiasporaFederation::Parsers::BaseParser

Inherits:
Object
  • Object
show all
Defined in:
lib/diaspora_federation/parsers/base_parser.rb

Overview

BaseParser is an abstract class which is used for defining parsers for different deserialization methods.

Direct Known Subclasses

JsonParser, XmlParser

Defined Under Namespace

Classes: InvalidRootNode

Instance Method Summary collapse

Constructor Details

#initialize(entity_type) ⇒ BaseParser


7
8
9
# File 'lib/diaspora_federation/parsers/base_parser.rb', line 7

def initialize(entity_type)
  @entity_type = entity_type
end

Instance Method Details

#parseObject

This method is abstract.

This method is used to parse input with a serialized object data. It returns a comprehensive data which must be enough to construct a DiasporaFederation::Entity instance.

Since parser method output is normally passed to a .from_hash method of an entity as arguments using * operator, the parse method must return an array of a size matching the number of arguments of .from_hash method of the entity type we link with

Raises:

  • (NotImplementedError)

18
19
20
# File 'lib/diaspora_federation/parsers/base_parser.rb', line 18

def parse(*)
  raise NotImplementedError.new("you must override this method when creating your own parser")
end