Class: Bartleby::HasManyOptions
- Inherits:
-
AssocOptions
- Object
- AssocOptions
- Bartleby::HasManyOptions
- Defined in:
- lib/bartleby/associatable.rb
Instance Attribute Summary
Attributes inherited from AssocOptions
#class_name, #foreign_key, #primary_key
Instance Method Summary collapse
-
#initialize(name, self_class_name, options = {}) ⇒ HasManyOptions
constructor
A new instance of HasManyOptions.
Methods inherited from AssocOptions
Constructor Details
#initialize(name, self_class_name, options = {}) ⇒ HasManyOptions
Returns a new instance of HasManyOptions.
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bartleby/associatable.rb', line 36 def initialize(name, self_class_name, = {}) defaults = { foreign_key: "#{self_class_name.underscore}_id".to_sym, primary_key: :id, class_name: name.to_s.singularize.capitalize } self.foreign_key = [:foreign_key] || defaults[:foreign_key] self.primary_key = [:primary_key] || defaults[:primary_key] self.class_name = [:class_name] || defaults[:class_name] end |