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.



1656
1657
1658
1659
# File 'lib/mxrb/dsl/builder.rb', line 1656

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

Instance Method Details

#on_type(type, &block) ⇒ Object



1661
1662
1663
# File 'lib/mxrb/dsl/builder.rb', line 1661

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

#otherwise(&block) ⇒ Object



1665
1666
1667
# File 'lib/mxrb/dsl/builder.rb', line 1665

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

#to_hObject



1669
1670
1671
# File 'lib/mxrb/dsl/builder.rb', line 1669

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