Class: Rosette::Core::SerializerConfig
- Inherits:
-
Object
- Object
- Rosette::Core::SerializerConfig
- Defined in:
- lib/rosette/core/extractor/serializer_config.rb
Overview
Configuration for a serializer. Should generally be configured using an instance of RepoConfig.
Instance Attribute Summary collapse
-
#klass ⇒ Class
readonly
The serializer’s class.
-
#name ⇒ String
readonly
The semantic name of this serializer.
-
#preprocessors ⇒ Array
readonly
A list of preprocessor configurations.
-
#serializer_id ⇒ String
readonly
The id of the serializer.
Instance Method Summary collapse
-
#add_preprocessor(preprocessor_id, &block) ⇒ void
Adds a pre-processor to this serializer config.
-
#initialize(name, klass, serializer_id) ⇒ SerializerConfig
constructor
Creates a new serializer config.
Constructor Details
#initialize(name, klass, serializer_id) ⇒ SerializerConfig
Creates a new serializer config.
35 36 37 38 39 40 |
# File 'lib/rosette/core/extractor/serializer_config.rb', line 35 def initialize(name, klass, serializer_id) @name = name @klass = klass @serializer_id = serializer_id @preprocessors = [] end |
Instance Attribute Details
#klass ⇒ Class (readonly)
Returns the serializer’s class.
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 |
# File 'lib/rosette/core/extractor/serializer_config.rb', line 27 class SerializerConfig attr_reader :name, :klass, :serializer_id, :preprocessors # Creates a new serializer config. # # @param [String] name The semantic name of this serializer. # @param [Class] klass The serializer's class. # @param [String] serializer_id The id of the serializer. def initialize(name, klass, serializer_id) @name = name @klass = klass @serializer_id = serializer_id @preprocessors = [] end # Adds a pre-processor to this serializer config. The given block # will be passed to the pre-processor's configurator, which will # in turn yield the configurator to you. # # @param [String] preprocessor_id The id of the preprocessor to add. # @return [void] def add_preprocessor(preprocessor_id, &block) klass = PreprocessorId.resolve(preprocessor_id) preprocessors << klass.configure(&block) end end |
#name ⇒ String (readonly)
Returns the semantic name of this serializer.
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 |
# File 'lib/rosette/core/extractor/serializer_config.rb', line 27 class SerializerConfig attr_reader :name, :klass, :serializer_id, :preprocessors # Creates a new serializer config. # # @param [String] name The semantic name of this serializer. # @param [Class] klass The serializer's class. # @param [String] serializer_id The id of the serializer. def initialize(name, klass, serializer_id) @name = name @klass = klass @serializer_id = serializer_id @preprocessors = [] end # Adds a pre-processor to this serializer config. The given block # will be passed to the pre-processor's configurator, which will # in turn yield the configurator to you. # # @param [String] preprocessor_id The id of the preprocessor to add. # @return [void] def add_preprocessor(preprocessor_id, &block) klass = PreprocessorId.resolve(preprocessor_id) preprocessors << klass.configure(&block) end end |
#preprocessors ⇒ Array (readonly)
Returns a list of preprocessor configurations.
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 |
# File 'lib/rosette/core/extractor/serializer_config.rb', line 27 class SerializerConfig attr_reader :name, :klass, :serializer_id, :preprocessors # Creates a new serializer config. # # @param [String] name The semantic name of this serializer. # @param [Class] klass The serializer's class. # @param [String] serializer_id The id of the serializer. def initialize(name, klass, serializer_id) @name = name @klass = klass @serializer_id = serializer_id @preprocessors = [] end # Adds a pre-processor to this serializer config. The given block # will be passed to the pre-processor's configurator, which will # in turn yield the configurator to you. # # @param [String] preprocessor_id The id of the preprocessor to add. # @return [void] def add_preprocessor(preprocessor_id, &block) klass = PreprocessorId.resolve(preprocessor_id) preprocessors << klass.configure(&block) end end |
#serializer_id ⇒ String (readonly)
Returns the id of the serializer.
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 |
# File 'lib/rosette/core/extractor/serializer_config.rb', line 27 class SerializerConfig attr_reader :name, :klass, :serializer_id, :preprocessors # Creates a new serializer config. # # @param [String] name The semantic name of this serializer. # @param [Class] klass The serializer's class. # @param [String] serializer_id The id of the serializer. def initialize(name, klass, serializer_id) @name = name @klass = klass @serializer_id = serializer_id @preprocessors = [] end # Adds a pre-processor to this serializer config. The given block # will be passed to the pre-processor's configurator, which will # in turn yield the configurator to you. # # @param [String] preprocessor_id The id of the preprocessor to add. # @return [void] def add_preprocessor(preprocessor_id, &block) klass = PreprocessorId.resolve(preprocessor_id) preprocessors << klass.configure(&block) end end |
Instance Method Details
#add_preprocessor(preprocessor_id, &block) ⇒ void
This method returns an undefined value.
Adds a pre-processor to this serializer config. The given block will be passed to the pre-processor’s configurator, which will in turn yield the configurator to you.
48 49 50 51 |
# File 'lib/rosette/core/extractor/serializer_config.rb', line 48 def add_preprocessor(preprocessor_id, &block) klass = PreprocessorId.resolve(preprocessor_id) preprocessors << klass.configure(&block) end |