Class: RbsActiverecord::Generator::Associations

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/rbs_activerecord/generator/associations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#format, #primary_key_type_for, #sql_type_to_class

Constructor Details

#initialize(model) ⇒ Associations

Returns a new instance of Associations.



11
12
13
# File 'lib/rbs_activerecord/generator/associations.rb', line 11

def initialize(model) #: void
  @model = model
end

Instance Attribute Details

#modelObject (readonly)

: RbsActiverecord::Model



8
9
10
# File 'lib/rbs_activerecord/generator/associations.rb', line 8

def model
  @model
end

Instance Method Details

#generateObject

: String



15
16
17
18
19
20
21
22
23
24
# File 'lib/rbs_activerecord/generator/associations.rb', line 15

def generate #: String
  <<~RBS.strip
    module GeneratedAssociationMethods
      #{has_many}
      #{has_one}
      #{belongs_to}
      #{has_and_belongs_to_many}
    end
  RBS
end