Class: HasManyOptions

Inherits:
AssocOptions show all
Defined in:
lib/reloj/orm/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(name, self_class_name, options = {}) ⇒ HasManyOptions

Returns a new instance of HasManyOptions.



34
35
36
37
38
39
40
41
42
43
# File 'lib/reloj/orm/associatable.rb', line 34

def initialize(name, self_class_name, options = {})
  defaults = {
    foreign_key: "#{self_class_name.to_s.underscore}_id".to_sym,
    primary_key: :id,
    class_name: name.to_s.singularize.camelcase
  }.merge(options)
  defaults.each do |attribute, value|
    self.send("#{attribute}=", value)
  end
end