Class: HasManyOptions

Inherits:
AssocOptions show all
Defined in:
lib/railz_lite/models/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.



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/railz_lite/models/associatable.rb', line 35

def initialize(name, self_class_name, options = {})
  foreign_key_sym = "#{self_class_name.underscore}_id".to_sym
  class_name_val = name.to_s.camelcase.singularize

  send("primary_key=", :id)
  send("foreign_key=", foreign_key_sym)
  send("class_name=", class_name_val)

  options.each do |attr, val|
    send("#{attr}=", val)
  end
end