Sha256: a37d17c6c47e86351c0f7559ddc9328fa8c42d21c3a42d991a9ecf8456983aee

Contents?: true

Size: 689 Bytes

Versions: 25

Compression:

Stored size: 689 Bytes

Contents

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

    delegate :sort_order, to: :free_form_section_type, allow_nil: true
    
    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

25 entries across 25 versions & 1 rubygems

Version Path
pulitzer-0.15.12 app/models/pulitzer/free_form_section.rb
pulitzer-0.15.11 app/models/pulitzer/free_form_section.rb
pulitzer-0.15.10 app/models/pulitzer/free_form_section.rb
pulitzer-0.15.9 app/models/pulitzer/free_form_section.rb
pulitzer-0.15.8 app/models/pulitzer/free_form_section.rb
pulitzer-0.15.7 app/models/pulitzer/free_form_section.rb
pulitzer-0.15.6 app/models/pulitzer/free_form_section.rb
pulitzer-0.15.5 app/models/pulitzer/free_form_section.rb
pulitzer-0.15.4 app/models/pulitzer/free_form_section.rb
pulitzer-0.15.3 app/models/pulitzer/free_form_section.rb
pulitzer-0.15.2 app/models/pulitzer/free_form_section.rb
pulitzer-0.15.1 app/models/pulitzer/free_form_section.rb
pulitzer-0.15.0 app/models/pulitzer/free_form_section.rb
pulitzer-0.14.4 app/models/pulitzer/free_form_section.rb
pulitzer-0.14.3 app/models/pulitzer/free_form_section.rb
pulitzer-0.14.2 app/models/pulitzer/free_form_section.rb
pulitzer-0.14.1 app/models/pulitzer/free_form_section.rb
pulitzer-0.14.0 app/models/pulitzer/free_form_section.rb
pulitzer-0.13.1 app/models/pulitzer/free_form_section.rb
pulitzer-0.12.5 app/models/pulitzer/free_form_section.rb