Class: Newsmlg2::Builder::Node
- Inherits:
-
Object
- Object
- Newsmlg2::Builder::Node
- Defined in:
- lib/newsmlg2/builder/node.rb
Overview
Wraps one model instance and exposes a DSL method per lutaml-model attribute. Methods are generated at wrap time from the attribute metadata, so unknown methods fail with a normal NoMethodError.
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#apply(&block) ⇒ Object
Runs a block against this node and returns the underlying model.
-
#initialize(model) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(model) ⇒ Node
Returns a new instance of Node.
9 10 11 12 |
# File 'lib/newsmlg2/builder/node.rb', line 9 def initialize(model) @model = model define_attribute_methods end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
14 15 16 |
# File 'lib/newsmlg2/builder/node.rb', line 14 def model @model end |
Instance Method Details
#apply(&block) ⇒ Object
Runs a block against this node and returns the underlying model.
17 18 19 20 |
# File 'lib/newsmlg2/builder/node.rb', line 17 def apply(&block) instance_eval(&block) if block @model end |