Class: FeaturedWork

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/featured_work.rb

Class Attributes collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#feature_limitInteger

Returns:

  • (Integer)


8
# File 'app/models/featured_work.rb', line 8

class_attribute :feature_limit, default: 5

#presenterObject

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

Returns:

  • (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_limitObject



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