Class: BelongsToOptions
- Inherits:
-
AssocOptions
- Object
- AssocOptions
- BelongsToOptions
- 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
-
#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.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/railz_lite/models/associatable.rb', line 21 def initialize(name, = {}) foreign_key_sym = "#{name}_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) .each do |attr, val| send("#{attr}=", val) end end |