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.



1690
1691
1692
1693
# File 'lib/mxrb/dsl/builder.rb', line 1690

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

Instance Method Details

#on_type(type, &block) ⇒ Object



1695
1696
1697
# File 'lib/mxrb/dsl/builder.rb', line 1695

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

#otherwise(&block) ⇒ Object



1699
1700
1701
# File 'lib/mxrb/dsl/builder.rb', line 1699

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

#to_hObject



1703
1704
1705
# File 'lib/mxrb/dsl/builder.rb', line 1703

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