Sha256: 2f28ddd6341646070b7d49e02028511eb4a51203ff1ef5fcaa241e8abac6c665

Contents?: true

Size: 612 Bytes

Versions: 6

Compression:

Stored size: 612 Bytes

Contents

module Pulitzer
  class FreeFormSection < ActiveRecord::Base
    belongs_to :version
    belongs_to :free_form_section_type
    has_many :partials, -> { order :sort_order}

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

    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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pulitzer-0.11.3 app/models/pulitzer/free_form_section.rb
pulitzer-0.11.2 app/models/pulitzer/free_form_section.rb
pulitzer-0.11.1 app/models/pulitzer/free_form_section.rb
pulitzer-0.11.0 app/models/pulitzer/free_form_section.rb
pulitzer-0.10.3 app/models/pulitzer/free_form_section.rb
pulitzer-0.10.2 app/models/pulitzer/free_form_section.rb