Class: FeaturedWork
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- FeaturedWork
- Defined in:
- app/models/featured_work.rb
Class Attributes collapse
Instance Attribute Summary collapse
-
#presenter ⇒ Object
Returns the value of attribute presenter.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#feature_limit ⇒ Integer
8 |
# File 'app/models/featured_work.rb', line 8 class_attribute :feature_limit, default: 5 |
#presenter ⇒ Object
Returns the value of attribute presenter.
22 23 24 |
# File 'app/models/featured_work.rb', line 22 def presenter @presenter end |
Class Method Details
.can_create_another? ⇒ Boolean
25 26 27 |
# File 'app/models/featured_work.rb', line 25 def can_create_another? FeaturedWork.count < feature_limit end |
Instance Method Details
#count_within_limit ⇒ Object
17 18 19 20 |
# File 'app/models/featured_work.rb', line 17 def count_within_limit return if FeaturedWork.can_create_another? errors.add(:base, "Limited to #{feature_limit} featured works.") end |