Module: ArDocStore::Embedding::InstanceMethods
- Defined in:
- lib/ar_doc_store/embedding.rb
Instance Method Summary collapse
-
#embed_valid?(assn_name, record) ⇒ Boolean
Returns whether or not the association is valid and applies any errors to the parent,
self, if it wasn’t. - #validate_embeds_many(assn_name) ⇒ Object
- #validate_embeds_one(assn_name) ⇒ Object
Instance Method Details
#embed_valid?(assn_name, record) ⇒ Boolean
Returns whether or not the association is valid and applies any errors to the parent, self, if it wasn’t. Skips any :autosave enabled records if they’re marked_for_destruction? or destroyed.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ar_doc_store/embedding.rb', line 24 def (assn_name, record) unless valid = record.valid? record.errors.each do |attribute, | attribute = "#{assn_name}.#{attribute}" errors[attribute] << errors[attribute].uniq! end end valid end |
#validate_embeds_many(assn_name) ⇒ Object
35 36 37 38 39 |
# File 'lib/ar_doc_store/embedding.rb', line 35 def (assn_name) if records = public_send(assn_name) records.each { |record| (assn_name, record) } end end |
#validate_embeds_one(assn_name) ⇒ Object
41 42 43 44 |
# File 'lib/ar_doc_store/embedding.rb', line 41 def (assn_name) record = public_send(assn_name) (assn_name, record) if record end |