Sha256: bb49e79da34d0f2c0edfab530e49b4bf26b905dec78aac24a623aec7b78fce01
Contents?: true
Size: 675 Bytes
Versions: 4
Compression:
Stored size: 675 Bytes
Contents
# frozen_string_literal: true class FeaturedWork < ActiveRecord::Base ## # @!group Class Attributes # # @!attribute feature_limit [r|w] # @return [Integer] class_attribute :feature_limit, default: 5 # @!endgroup Class Attributes ## validate :count_within_limit, on: :create validates :order, inclusion: { in: proc { 0..feature_limit } } default_scope { order(:order) } def count_within_limit return if FeaturedWork.can_create_another? errors.add(:base, "Limited to #{feature_limit} featured works.") end attr_accessor :presenter class << self def can_create_another? FeaturedWork.count < feature_limit end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
hyrax-5.0.2 | app/models/featured_work.rb |
hyrax-5.0.1 | app/models/featured_work.rb |
hyrax-5.0.0 | app/models/featured_work.rb |
hyrax-5.0.0.rc3 | app/models/featured_work.rb |