Sha256: 4fdf76c1a8f146d37d2c88108c4c4e6384ed7f4f161e7bf6909595006fe6823a
Contents?: true
Size: 860 Bytes
Versions: 2
Compression:
Stored size: 860 Bytes
Contents
module Annotator module InitialDescription # Initial descriptions for columns associated with belongs_to class BelongsTo < Base def check # check if there is belongs to association where this column is a foreign key @model.reflect_on_all_associations.each do |reflection| if reflection.foreign_key == @column && reflection.macro == :belongs_to @reflection = reflection return true end end # Polymorphic association type column if @column.ends_with? '_type' return true if @reflection = @model.reflect_on_association(@column.match(/(.*?)_type$/)[1].to_sym) end return false end def text "belongs to :#{@reflection.name}#{@reflection.options[:polymorphic] ? ' (polymorphic)' : ''}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
annotator-0.0.6 | lib/annotator/initial_description/belongs_to.rb |
annotator-0.0.5 | lib/annotator/initial_description/belongs_to.rb |