Module: WorksCited::Mixins::HasWorksCited::InstanceMethods

Defined in:
lib/works_cited/mixins/has_works_cited.rb

Overview

Included by has_works_cited mixin

Instance Method Summary collapse

Instance Method Details

#works_cited_citations_attributes=(raw_citations) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/works_cited/mixins/has_works_cited.rb', line 25

def works_cited_citations_attributes=(raw_citations)
  array = []
  raw_citations&.each do |_index, citation|
    destroy = citation.delete(:_destroy)
    if destroy == '1'
      Citation.find(citation[:id]).destroy if citation[:id]
      next
    end

    array << citation
  end
  super array
end