Sha256: 933e65af9d79988c7a81686d492015f259c188e1e2ed99a427b10c9c44182614

Contents?: true

Size: 482 Bytes

Versions: 10

Compression:

Stored size: 482 Bytes

Contents

module Hyrax::Works
  module Featured
    extend ActiveSupport::Concern
    included do
      before_destroy :cleanup_featured_works
      after_save :check_featureability
    end

    def cleanup_featured_works
      FeaturedWork.where(work_id: id).destroy_all
    end

    def check_featureability
      return unless private?
      cleanup_featured_works if featured?
    end

    def featured?
      return true if FeaturedWork.find_by_work_id(id)
      false
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 app/models/concerns/hyrax/works/featured.rb
hyrax-1.1.0 app/models/concerns/hyrax/works/featured.rb
hyrax-1.0.5 app/models/concerns/hyrax/works/featured.rb
hyrax-1.0.4 app/models/concerns/hyrax/works/featured.rb
hyrax-1.0.3 app/models/concerns/hyrax/works/featured.rb
hyrax-1.0.2 app/models/concerns/hyrax/works/featured.rb
hyrax-1.0.1 app/models/concerns/hyrax/works/featured.rb
hyrax-1.0.0.rc2 app/models/concerns/hyrax/works/featured.rb
hyrax-1.0.0.rc1 app/models/concerns/hyrax/works/featured.rb
test_hyrax-0.0.1.alpha app/models/concerns/hyrax/works/featured.rb