Class: Bartleby::BelongsToOptions
- Inherits:
-
AssocOptions
- Object
- AssocOptions
- Bartleby::BelongsToOptions
- 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, options = {}) ⇒ BelongsToOptions
constructor
A new instance of BelongsToOptions.
Methods inherited from AssocOptions
Constructor Details
#initialize(name, options = {}) ⇒ BelongsToOptions
Returns a new instance of BelongsToOptions.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bartleby/associatable.rb', line 22 def initialize(name, = {}) defaults = { foreign_key: "#{name}_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 |