Class: Serial::Builder Private
- Inherits:
-
Object
- Object
- Serial::Builder
- Defined in:
- lib/serial/builder.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Builder contains common methods to the serializer DSL.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Array, Hash
readonly
private
Builder data, depends on what kind of builder it is.
Class Method Summary collapse
-
.build(context, *args) {|self, *args| ... } ⇒ #data
private
Create the builder, execute the block inside it, and return its’ data.
Instance Method Summary collapse
-
#exec(*args) {|self, *args| ... } ⇒ Object
private
Executes a block in the configured context, if there is one, otherwise using regular closure scoping.
Instance Attribute Details
permalink #data ⇒ Array, Hash (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Builder data, depends on what kind of builder it is.
22 23 24 |
# File 'lib/serial/builder.rb', line 22 def data @data end |
Class Method Details
permalink .build(context, *args) {|self, *args| ... } ⇒ #data
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create the builder, execute the block inside it, and return its’ data. Any superflous arguments are given to #exec.
13 14 15 16 17 |
# File 'lib/serial/builder.rb', line 13 def self.build(context, *args, &block) builder = new(context) builder.exec(*args, &block) builder.data end |
Instance Method Details
permalink #exec(*args) {|self, *args| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Executes a block in the configured context, if there is one, otherwise using regular closure scoping.
30 31 32 33 34 35 36 37 38 |
# File 'lib/serial/builder.rb', line 30 def exec(*args, &block) if @context @context.instance_exec(self, *args, &block) elsif block block.call(self, *args) else raise ArgumentError, "no serializer block given" end end |