Class: BelongsToOptions
- Inherits:
-
AssocOptions
- Object
- AssocOptions
- BelongsToOptions
- Defined in:
- lib/laris/larisrecord/associatable.rb
Instance Attribute Summary
Attributes inherited from AssocOptions
#class_name, #foreign_key, #primary_key
Instance Method Summary collapse
-
#initialize(assoc_name, options = {}) ⇒ BelongsToOptions
constructor
A new instance of BelongsToOptions.
Methods inherited from AssocOptions
Constructor Details
#initialize(assoc_name, options = {}) ⇒ BelongsToOptions
Returns a new instance of BelongsToOptions.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/laris/larisrecord/associatable.rb', line 14 def initialize(assoc_name, = {}) defaults = { class_name: assoc_name.to_s.camelcase, foreign_key: "#{assoc_name}_id".to_sym, primary_key: :id } defaults.each do |attr, default| send("#{attr}=", ([attr] || default)) end end |