Method: Infold::ModelWriter#delegate_code

Defined in:
lib/infold/writers/model_writer.rb

#delegate_codeObject



37
38
39
40
41
42
43
# File 'lib/infold/writers/model_writer.rb', line 37

def delegate_code
  code = ''
  @resource.associations&.select { |as| as.belongs_to? && as.name_field != 'id' }&.each do |association|
    code += "delegate :#{association.name_field}, to: :#{association.name}, prefix: true, allow_nil: true\n"
  end
  indent(code, 2).presence
end