Class: Uniword::Builder::BaseBuilder
- Inherits:
-
Object
- Object
- Uniword::Builder::BaseBuilder
- Defined in:
- lib/uniword/builder/base_builder.rb
Overview
Base class for builders that wrap a single model object.
Provides the shared initialize/from_model/build pattern used by most builders in the module. Subclasses must implement .default_model_class to specify the model type to create when none is provided.
Direct Known Subclasses
DocumentBuilder, NumberingBuilder, ParagraphBuilder, RunBuilder, SdtBuilder, SectionBuilder, TableBuilder, TableCellBuilder, TableRowBuilder
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(model = nil) ⇒ BaseBuilder
constructor
A new instance of BaseBuilder.
Constructor Details
#initialize(model = nil) ⇒ BaseBuilder
Returns a new instance of BaseBuilder.
26 27 28 |
# File 'lib/uniword/builder/base_builder.rb', line 26 def initialize(model = nil) @model = model || self.class.default_model_class.new end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
24 25 26 |
# File 'lib/uniword/builder/base_builder.rb', line 24 def model @model end |
Class Method Details
.default_model_class ⇒ Object
38 39 40 41 |
# File 'lib/uniword/builder/base_builder.rb', line 38 def self.default_model_class raise NotImplementedError, "#{name} must implement .default_model_class" end |
.from_model(model) ⇒ Object
30 31 32 |
# File 'lib/uniword/builder/base_builder.rb', line 30 def self.from_model(model) new(model) end |
Instance Method Details
#build ⇒ Object
34 35 36 |
# File 'lib/uniword/builder/base_builder.rb', line 34 def build @model end |