Class: HasManyOptions

Inherits:
AssocOptions show all
Defined in:
lib/laris/larisrecord/associatable.rb

Instance Attribute Summary

Attributes inherited from AssocOptions

#class_name, #foreign_key, #primary_key

Instance Method Summary collapse

Methods inherited from AssocOptions

#model_class, #table_name

Constructor Details

#initialize(assoc_name, self_name, options = {}) ⇒ HasManyOptions

Returns a new instance of HasManyOptions.



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/laris/larisrecord/associatable.rb', line 28

def initialize(assoc_name, self_name, options = {})
  defaults = {
    class_name: assoc_name.to_s.singularize.camelcase,
    foreign_key: "#{self_name.underscore}_id".to_sym,
    primary_key: :id
  }

  defaults.each do |attr, default|
    send("#{attr}=", (options[attr] || default))
  end
end