Class: Mxrb::Dsl::TypeDecisionBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/mxrb/dsl/builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(variable) ⇒ TypeDecisionBuilder

Returns a new instance of TypeDecisionBuilder.



1558
1559
1560
1561
# File 'lib/mxrb/dsl/builder.rb', line 1558

def initialize(variable)
  @variable = variable
  @branches = {}
end

Instance Method Details

#on_type(type, &block) ⇒ Object



1563
1564
1565
# File 'lib/mxrb/dsl/builder.rb', line 1563

def on_type(type, &block)
  add_branch(type.to_s, &block)
end

#otherwise(&block) ⇒ Object



1567
1568
1569
# File 'lib/mxrb/dsl/builder.rb', line 1567

def otherwise(&block)
  add_branch("", &block)
end

#to_hObject



1571
1572
1573
# File 'lib/mxrb/dsl/builder.rb', line 1571

def to_h
  { type: :inheritance_decision, variable: @variable, branches: @branches }
end