Class: Pulitzer::FreeFormSection

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/pulitzer/free_form_section.rb

Instance Method Summary collapse

Instance Method Details

#clone_meObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/pulitzer/free_form_section.rb', line 13

def clone_me
  clone_attrs = self.attributes.dup
  clone_attrs.delete 'id'
  clone_attrs.delete 'version_id'

  my_clone = Pulitzer::FreeFormSection.create!(clone_attrs)
  partials.each do |partial|
    cloned_partial = partial.clone_me
    my_clone.partials << cloned_partial
  end
  my_clone
end

#partial(name) ⇒ Object



9
10
11
# File 'app/models/pulitzer/free_form_section.rb', line 9

def partial(name)
  self.partials.to_a.detect{|ffs| ffs.name == name}
end