Sha256: a17bd4149fffe1008864456a43e7ebadf1ce1c822f6e0c642ed76a03031c0a17

Contents?: true

Size: 614 Bytes

Versions: 5

Compression:

Stored size: 614 Bytes

Contents

class Pulitzer::PostType < ActiveRecord::Base
  enum kind: [ :template, :free_form, :hybrid ]
  has_many :posts, dependent: :destroy
  has_many :post_type_content_element_types, dependent: :destroy
  has_many :content_element_types, through: :post_type_content_element_types

  validates :name, presence: true

  def self.named(label)
    self.find_by(name: label)
  end

  def singular?
    !plural
  end

  def singleton_post
    posts.first
  end

  def singleton_post?
    !!singleton_post
  end

  def allow_template?
    template? || hybrid?
  end

  def allow_free_form?
    free_form? || hybrid?
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pulitzer-0.1.7 app/models/pulitzer/post_type.rb
pulitzer-0.1.6 app/models/pulitzer/post_type.rb
pulitzer-0.1.5 app/models/pulitzer/post_type.rb
pulitzer-0.1.4 app/models/pulitzer/post_type.rb
pulitzer-0.1.3 app/models/pulitzer/post_type.rb