Class: FeaturedWork

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

Constant Summary collapse

FEATURE_LIMIT =
5

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#generic_file_solr_documentObject

Returns the value of attribute generic_file_solr_document.



14
15
16
# File 'app/models/featured_work.rb', line 14

def generic_file_solr_document
  @generic_file_solr_document
end

Class Method Details

.can_create_another?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'app/models/featured_work.rb', line 17

def can_create_another?
  FeaturedWork.count < FEATURE_LIMIT
end

Instance Method Details

#count_within_limitObject



8
9
10
11
12
# File 'app/models/featured_work.rb', line 8

def count_within_limit
  unless FeaturedWork.can_create_another?
    errors.add(:base, "Limited to #{FEATURE_LIMIT} featured works.")
  end
end