Class: Tapioca::Dsl::Compilers::Operandi
- Inherits:
-
Compiler
- Object
- Compiler
- Tapioca::Dsl::Compilers::Operandi
- Extended by:
- T::Sig
- Defined in:
- lib/tapioca/dsl/compilers/operandi.rb
Overview
Tapioca DSL compiler for Operandi
Generates RBI signatures for methods automatically defined by the
arg/argument and output DSL macros in operandi.
For each argument and output, three methods are generated:
- Getter:
def name- returns the value - Predicate:
def name?- returns boolean - Setter:
def name=(private) - sets the value
Additionally, typed inner classes are generated:
Arguments- T::Struct representing all service argumentsOutputs- T::Struct representing all service outputs
Constant Summary collapse
- ConstantType =
type_member { { fixed: T.class_of(::Operandi::Base) } }
- CONFIG_TYPE =
"T::Hash[T.any(::String, ::Symbol), T.untyped]"- SERVICE_OR_CONFIG_TYPE =
"T.any(::Operandi::Base, #{CONFIG_TYPE})".freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
Instance Method Details
#decorate ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/tapioca/dsl/compilers/operandi.rb', line 99 def decorate root.create_path(constant) do |klass| # Generate class methods (.run, .run!, .with) generate_class_methods(klass) # Generate typed inner classes for arguments and outputs generate_arguments_type(klass) generate_outputs_type(klass) # Generate argument methods constant.arguments.each_value do |field| generate_field_methods(klass, field) end # Generate output methods constant.outputs.each_value do |field| generate_field_methods(klass, field) end end end |