Module: ActiveFedora::Rdf::NestedAttributes::ClassMethods

Defined in:
lib/active_fedora/rdf/nested_attributes.rb

Instance Method Summary collapse

Instance Method Details

#accepts_nested_attributes_for(*attr_names) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/active_fedora/rdf/nested_attributes.rb', line 86

def accepts_nested_attributes_for *attr_names
  options = { :allow_destroy => false, :update_only => false }
  options.update(attr_names.extract_options!)
  options.assert_valid_keys(:allow_destroy, :reject_if, :limit, :update_only)
  options[:reject_if] = REJECT_ALL_BLANK_PROC if options[:reject_if] == :all_blank

  attr_names.each do |association_name|
    nested_attributes_options = self.nested_attributes_options.dup
    nested_attributes_options[association_name] = options
    self.nested_attributes_options = nested_attributes_options

    generate_association_writer(association_name)
  end
end