rails-refresher/app/models/concerns/visible.rb
Tyrel Souza 8a91d51c39
finish
2024-07-04 21:00:08 -04:00

20 lines
322 B
Ruby

module Visible
extend ActiveSupport::Concern
VALID_STATUSES = ['public', 'private', 'archived']
included do
validates :status, inclusion: { in: VALID_STATUSES }
end
class_methods do
def public_count
where(status: 'public').count
end
end
def archived?
status == 'archived'
end
end