Class: Newsmlg2::Builder::Node

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#modelObject (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