Thursday, September 19, 2024 11:52:19 PM
> settings

Customize


Authenticate

> project.rb
# frozen_string_literal: true

class Project < ApplicationRecord
  CACHES = {}

  ###########################################
  # Attributes
  attribute :public_id, :slug
  attribute :name, :string
  attribute :os_path, :pathname
  attribute :allowed_paths, :pathnames, default: []
  attribute :disallowed_paths, :pathnames, default: []
  attribute :role_visibility, :roles_as_array
  attribute :description, :string
  attribute :links, :hash
  attribute :start_date, :date
  attribute :end_date, :date
  attribute :created_at, :datetime
  attribute :updated_at, :datetime

  ###########################################
  # Associations
  has_many :filters, class_name: "ProjectFilter", dependent: :destroy

  ###########################################
  # Scopes

  ###########################################

  def entries
    CACHES[id] ||= Cache.new(os_path, allowed_paths, disallowed_paths)
  end

  def readme
    cache.find("README.md")
  end

  def active_years
    return if start_date.nil?

    start_date.year..(end_date || Date.today).year
  end
end
All opinions represented herein are my own
- © 2024 itsthedevman
- build 3c15a1b