Class: RbsShrine::Shrine::Generator

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/rbs_shrine/shrine.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#format, #klass_to_names

Constructor Details

#initialize(klass) ⇒ Generator

Returns a new instance of Generator.



24
25
26
27
# File 'lib/rbs_shrine/shrine.rb', line 24

def initialize(klass) #: void
  @klass = klass
  @klass_name = klass.name || ""
end

Instance Attribute Details

#klassObject (readonly)

: singleton(ActiveRecord::Base)



20
21
22
# File 'lib/rbs_shrine/shrine.rb', line 20

def klass
  @klass
end

#klass_nameObject (readonly)

: String



21
22
23
# File 'lib/rbs_shrine/shrine.rb', line 21

def klass_name
  @klass_name
end

Instance Method Details

#generateObject

: String



29
30
31
32
33
34
35
36
37
# File 'lib/rbs_shrine/shrine.rb', line 29

def generate #: String
  format <<~RBS
    # resolve-type-names: false

    #{header}
      #{methods}
    #{footer}
  RBS
end