Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/models/reflection.rb,
lib/models/nested_attributes.rb
Class Method Summary collapse
- .accepts_nested_attributes_for_with_inheritance_management(*attr_names) ⇒ Object
- .alert_subclasses_of_new_nested_attributes ⇒ Object
- .alert_subclasses_of_new_reflection(name, reflection) ⇒ Object
- .create_reflection_with_inheritance_management(macro, name, options, active_record) ⇒ Object
- .superclass_created_new_reflection(name, reflection) ⇒ Object
- .superclass_received_nested_attributes(super_nested_attr_options) ⇒ Object
Class Method Details
.accepts_nested_attributes_for_with_inheritance_management(*attr_names) ⇒ Object
7 8 9 10 |
# File 'lib/models/nested_attributes.rb', line 7 def accepts_nested_attributes_for_with_inheritance_management(*attr_names) accepts_nested_attributes_for_without_inheritance_management(*attr_names) alert_subclasses_of_new_nested_attributes end |
.alert_subclasses_of_new_nested_attributes ⇒ Object
13 14 15 16 17 |
# File 'lib/models/nested_attributes.rb', line 13 def alert_subclasses_of_new_nested_attributes subclasses.each do |subclass| subclass.superclass_received_nested_attributes() end end |
.alert_subclasses_of_new_reflection(name, reflection) ⇒ Object
14 15 16 17 18 |
# File 'lib/models/reflection.rb', line 14 def alert_subclasses_of_new_reflection(name, reflection) subclasses.each do |subclass| subclass.superclass_created_new_reflection(name, reflection) end end |
.create_reflection_with_inheritance_management(macro, name, options, active_record) ⇒ Object
7 8 9 10 11 |
# File 'lib/models/reflection.rb', line 7 def create_reflection_with_inheritance_management(macro, name, , active_record) reflection = create_reflection_without_inheritance_management(macro, name, , active_record) alert_subclasses_of_new_reflection(name, reflection) reflection end |
.superclass_created_new_reflection(name, reflection) ⇒ Object
20 21 22 23 |
# File 'lib/models/reflection.rb', line 20 def superclass_created_new_reflection(name, reflection) return if reflections[name] write_inheritable_hash :reflections, name => reflection end |
.superclass_received_nested_attributes(super_nested_attr_options) ⇒ Object
19 20 21 22 23 |
# File 'lib/models/nested_attributes.rb', line 19 def superclass_received_nested_attributes() .update() do |hash, oldval, newval| oldval.nil? ? newval : oldval end end |