Class: DiasporaFederation::Parsers::BaseParser
- Inherits:
-
Object
- Object
- DiasporaFederation::Parsers::BaseParser
- 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
Defined Under Namespace
Classes: InvalidRootNode
Instance Method Summary collapse
-
#initialize(entity_type) ⇒ BaseParser
constructor
A new instance of BaseParser.
-
#parse ⇒ Object
abstract
This method is used to parse input with a serialized object data.
Constructor Details
#initialize(entity_type) ⇒ BaseParser
Returns a new instance of BaseParser.
9 10 11 |
# File 'lib/diaspora_federation/parsers/base_parser.rb', line 9 def initialize(entity_type) @entity_type = entity_type end |
Instance Method Details
#parse ⇒ Object
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
20 21 22 |
# File 'lib/diaspora_federation/parsers/base_parser.rb', line 20 def parse(*) raise NotImplementedError.new("you must override this method when creating your own parser") end |