Module: Abyme::Model::ClassMethods

Defined in:
lib/abyme/model.rb

Instance Method Summary collapse

Instance Method Details

#abyme_attributesObject



15
16
17
# File 'lib/abyme/model.rb', line 15

def abyme_attributes
  Abyme::Model.instance_variable_get(:@permitted_attributes)[name]
end

#abymize(association, permit: nil, reject: nil, class_name: nil, **options) ⇒ Object Also known as: abyme_for



4
5
6
7
8
9
10
11
# File 'lib/abyme/model.rb', line 4

def abymize(association, permit: nil, reject: nil, class_name: nil, **options)
  default_options = {reject_if: :all_blank, allow_destroy: true}
  nested_attributes_options = default_options.merge(options)
  accepts_nested_attributes_for association, nested_attributes_options
  # Save allow_destroy value for this model/association for later
  save_destroy_option(association, nested_attributes_options[:allow_destroy])
  Abyme::Model.permit_attributes(name, association, permit || reject, permit.present?, class_name) if permit.present? || reject.present?
end