Class: SmartSeeds::Generator::ForeignKey
- Defined in:
- lib/smart_seeds/generator/integer/foreign_key.rb
Instance Method Summary collapse
- #generate_value ⇒ Object
-
#initialize(column, model) ⇒ ForeignKey
constructor
A new instance of ForeignKey.
- #is_a_foreign_key? ⇒ Boolean
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_value ⇒ Object
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
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 |