Class: Sinicum::Jcr::TypeTranslator

Inherits:
Object
  • Object
show all
Defined in:
lib/sinicum/jcr/type_translator.rb

Overview

Public: Manages TypeTranslators in a Rails Middleware inspired way.

A TypeTranslator is a class that translates the information on a node given by the node’s JSON representation in a class that will be initialized with the node’s data. Please note, that DefaultTranslator should always be the last translator in the array.

Constant Summary collapse

DEFAULT_TRANSLATORS =
[
Sinicum::Jcr::TypeTranslators::DataTranslator,
Sinicum::Jcr::TypeTranslators::DamTranslator,
Sinicum::Jcr::TypeTranslators::ComponentTranslator,
Sinicum::Jcr::TypeTranslators::DefaultTranslator]

Class Method Summary collapse

Class Method Details

.clearObject



25
26
27
# File 'lib/sinicum/jcr/type_translator.rb', line 25

def self.clear
  @translators = []
end

.listObject



21
22
23
# File 'lib/sinicum/jcr/type_translator.rb', line 21

def self.list
  translators
end

.resetObject



29
30
31
# File 'lib/sinicum/jcr/type_translator.rb', line 29

def self.reset
  @translators = DEFAULT_TRANSLATORS.dup
end

.translatorsObject



33
34
35
# File 'lib/sinicum/jcr/type_translator.rb', line 33

def self.translators
  @translators ||= DEFAULT_TRANSLATORS.dup
end

.use(clazz) ⇒ Object



17
18
19
# File 'lib/sinicum/jcr/type_translator.rb', line 17

def self.use(clazz)
  translators.insert(0, clazz)
end