Class: Synthra::Parser::AST::BehaviorNode
- Defined in:
- lib/synthra/parser/ast.rb
Overview
Behavior annotation node
Represents a behavior declaration at schema or field level. Behaviors modify generation (latency, failure) or set metadata (seed).
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(name:, value:, line: nil) ⇒ BehaviorNode
constructor
Create a new BehaviorNode.
-
#to_behavior ⇒ Hash
Convert to behavior configuration hash for schema-level.
-
#to_field_behavior ⇒ Synthra::FieldBehavior
Convert to FieldBehavior for field-level behaviors.
Constructor Details
#initialize(name:, value:, line: nil) ⇒ BehaviorNode
Create a new BehaviorNode
380 381 382 383 384 |
# File 'lib/synthra/parser/ast.rb', line 380 def initialize(name:, value:, line: nil) super(line: line) @name = name.to_sym @value = value end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
365 366 367 |
# File 'lib/synthra/parser/ast.rb', line 365 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
371 372 373 |
# File 'lib/synthra/parser/ast.rb', line 371 def value @value end |
Instance Method Details
#to_behavior ⇒ Hash
Convert to behavior configuration hash for schema-level
400 401 402 |
# File 'lib/synthra/parser/ast.rb', line 400 def to_behavior { name: name, value: value } end |
#to_field_behavior ⇒ Synthra::FieldBehavior
Convert to FieldBehavior for field-level behaviors
391 392 393 |
# File 'lib/synthra/parser/ast.rb', line 391 def to_field_behavior FieldBehavior.new(type: name, value: value) end |