Class: Tapioca::Compilers::Encryptable

Inherits:
Dsl::Compiler
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/tapioca/dsl/compilers/architecture_compiler.rb

Constant Summary collapse

ConstantType =
type_member { { fixed: T.class_of(Udb::Architecture) } }

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.gather_constantsEnumerable<Module>

Returns:

  • (Enumerable<Module>)


19
20
21
# File 'lib/tapioca/dsl/compilers/architecture_compiler.rb', line 19

def self.gather_constants
  [Udb::Architecture]
end

Instance Method Details

#decorate

This method returns an undefined value.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/tapioca/dsl/compilers/architecture_compiler.rb', line 24

def decorate
  # Create a RBI definition for each class that includes Encryptable
  root.create_path(constant) do |klass|
    Udb::Architecture::OBJS.each do |obj_data|
      plural_fn = ActiveSupport::Inflector.pluralize(obj_data[:fn_name])

      klass.create_method(plural_fn, return_type: "T::Array[#{obj_data[:klass]}]")
      klass.create_method("#{obj_data[:fn_name]}_hash", return_type: "T::Hash[String, #{obj_data[:klass]}]")
      klass.create_method(obj_data[:fn_name], parameters: [create_param("name", type: "String")], return_type: "T.nilable(#{obj_data[:klass]})")
    end
  end
end