Sha256: 8a8b2ab53b8ee51b06d874e69a5a3c9e96c7890940ffd9048094ab71396c7c14

Contents?: true

Size: 456 Bytes

Versions: 6

Compression:

Stored size: 456 Bytes

Contents

class Pulitzer::PostType < ActiveRecord::Base
  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 singular?
    !plural
  end

  def singleton_post
    posts.first
  end

  def singleton_post?
    !!singleton_post
  end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pulitzer-0.1.2 app/models/pulitzer/post_type.rb
pulitzer-0.1.1 app/models/pulitzer/post_type.rb
pulitzer-0.1.0 app/models/pulitzer/post_type.rb
pulitzer-0.0.5 app/models/pulitzer/post_type.rb
pulitzer-0.0.4 app/models/pulitzer/post_type.rb
pulitzer-0.0.3 app/models/pulitzer/post_type.rb