Sha256: 47a9a81e8f100b80b5c31d59611f5922b7cfb1939131c4d4bf29a1c81076ead8

Contents?: true

Size: 886 Bytes

Versions: 25

Compression:

Stored size: 886 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
      if label.present?
        label
      else
        default_label
      end
    end

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

    private

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

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.9 app/models/spotlight/main_navigation.rb
blacklight-spotlight-3.0.0.alpha.8 app/models/spotlight/main_navigation.rb
blacklight-spotlight-3.0.0.alpha.7 app/models/spotlight/main_navigation.rb
blacklight-spotlight-3.0.0.alpha.6 app/models/spotlight/main_navigation.rb
blacklight-spotlight-3.0.0.alpha.5 app/models/spotlight/main_navigation.rb
blacklight-spotlight-3.0.0.alpha.4 app/models/spotlight/main_navigation.rb
blacklight-spotlight-3.0.0.alpha.3 app/models/spotlight/main_navigation.rb
blacklight-spotlight-3.0.0.alpha.2 app/models/spotlight/main_navigation.rb
blacklight-spotlight-3.0.0.alpha.1 app/models/spotlight/main_navigation.rb
blacklight-spotlight-2.13.0 app/models/spotlight/main_navigation.rb
blacklight-spotlight-2.12.1 app/models/spotlight/main_navigation.rb
blacklight-spotlight-2.12.0 app/models/spotlight/main_navigation.rb
blacklight-spotlight-2.11.0 app/models/spotlight/main_navigation.rb
blacklight-spotlight-2.10.0 app/models/spotlight/main_navigation.rb
blacklight-spotlight-2.9.0 app/models/spotlight/main_navigation.rb
blacklight-spotlight-2.8.0 app/models/spotlight/main_navigation.rb
blacklight-spotlight-2.7.2 app/models/spotlight/main_navigation.rb
blacklight-spotlight-2.7.1 app/models/spotlight/main_navigation.rb
blacklight-spotlight-2.7.0 app/models/spotlight/main_navigation.rb
blacklight-spotlight-2.6.1.1 app/models/spotlight/main_navigation.rb