Sha256: aa433312d28e0048f58bcba2f819a4945af9822d031319eeee7c220bf6e59af7

Contents?: true

Size: 927 Bytes

Versions: 19

Compression:

Stored size: 927 Bytes

Contents

module Pulitzer
  class FreeFormSectionType < Pulitzer::ApplicationRecord
    include Pulitzer::PostTypeElement

    belongs_to :post_type_version
    has_many :free_form_sections
    has_many :partial_types, -> { order :id }

    accepts_nested_attributes_for :partial_types
    
    def self.export_config
      {
        except: [:id,:post_type_version_id],
        include: {
          partial_types: PartialType.export_config
        }
      }
    end

    def self.convert_nested_assoc(json_hash)
      json_hash[attrs_name].map!{|p_attrs|
        new_attrs = Pulitzer::PartialType.convert_hash_to_nested p_attrs
      }
      json_hash      
    end

    def first_partial_type
      partial_types.first
    end

    def clone_me
      clone_attrs = self.attributes.dup
      clone_attrs.delete 'id'
      clone_attrs.delete 'post_type_version_id'
      Pulitzer::FreeFormSectionType.new(clone_attrs)
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
pulitzer-0.15.31 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.30 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.29 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.28 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.27 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.26 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.25 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.24 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.23 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.22 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.21 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.20 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.19 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.18 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.17 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.16 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.15 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.14 app/models/pulitzer/free_form_section_type.rb
pulitzer-0.15.13 app/models/pulitzer/free_form_section_type.rb