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



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

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



7
8
9
# File 'app/models/pulitzer/free_form_section.rb', line 7

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