Class: SmartSeeds::Generator::ForeignKey

Inherits:
Integer
  • Object
show all
Defined in:
lib/smart_seeds/generator/integer/foreign_key.rb

Instance Method Summary collapse

Constructor Details

#initialize(column, model) ⇒ ForeignKey

Returns a new instance of ForeignKey.



4
5
6
# File 'lib/smart_seeds/generator/integer/foreign_key.rb', line 4

def initialize(column, model)
  super
end

Instance Method Details

#generate_valueObject



8
9
10
11
# File 'lib/smart_seeds/generator/integer/foreign_key.rb', line 8

def generate_value
  klass = convert_column_name.constantize
  klass.ids.sample
end

#is_a_foreign_key?Boolean

Returns:



13
14
15
# File 'lib/smart_seeds/generator/integer/foreign_key.rb', line 13

def is_a_foreign_key?
  true if splitted_column_name.last == 'id'
end