Sha256: 3934bedf86ab5b80aab02978e561ffde02500297526814fb9dbc6019d2f0481b

Contents?: true

Size: 865 Bytes

Versions: 24

Compression:

Stored size: 865 Bytes

Contents

# frozen_string_literal: true

module Spotlight
  ##
  # Exhibit navbar links
  class MainNavigation < ActiveRecord::Base
    include Spotlight::Translatables

    belongs_to :exhibit, touch: true
    default_scope { order('weight ASC') }
    scope :browse, -> { find_by(nav_type: 'browse') }
    scope :about, -> { find_by(nav_type: 'about') }
    scope :curated_features, -> { find_by(nav_type: 'curated_features') }
    scope :displayable, -> { where(display: true) }
    translates :label

    def displayable?
      display?
    end

    def label_or_default
      label.presence || default_label
    end

    def default_label(**options)
      I18n.t(:"spotlight.main_navigation.#{nav_type}", **options)
    end

    private

    ##
    # Allows us to scope translations namespace.
    def slug
      ['main_navigation', nav_type].join('.')
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
blacklight-spotlight-4.3.6 app/models/spotlight/main_navigation.rb
blacklight-spotlight-4.3.5 app/models/spotlight/main_navigation.rb
blacklight-spotlight-4.3.4 app/models/spotlight/main_navigation.rb
blacklight-spotlight-4.3.3 app/models/spotlight/main_navigation.rb
blacklight-spotlight-4.3.2 app/models/spotlight/main_navigation.rb
blacklight-spotlight-4.3.1 app/models/spotlight/main_navigation.rb
blacklight-spotlight-4.3.0 app/models/spotlight/main_navigation.rb
blacklight-spotlight-4.2.0 app/models/spotlight/main_navigation.rb
blacklight-spotlight-4.1.2 app/models/spotlight/main_navigation.rb
blacklight-spotlight-4.1.1 app/models/spotlight/main_navigation.rb
blacklight-spotlight-4.1.0 app/models/spotlight/main_navigation.rb
blacklight-spotlight-4.0.3 app/models/spotlight/main_navigation.rb
blacklight-spotlight-4.0.2 app/models/spotlight/main_navigation.rb
blacklight-spotlight-4.0.1 app/models/spotlight/main_navigation.rb
blacklight-spotlight-4.0.0 app/models/spotlight/main_navigation.rb
blacklight-spotlight-3.6.0.beta10 app/models/spotlight/main_navigation.rb
blacklight-spotlight-3.6.0.beta9 app/models/spotlight/main_navigation.rb
blacklight-spotlight-3.6.0.beta8 app/models/spotlight/main_navigation.rb
blacklight-spotlight-3.6.0.beta7 app/models/spotlight/main_navigation.rb
blacklight-spotlight-3.6.0.beta6 app/models/spotlight/main_navigation.rb