# 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