Sha256: 618986c459c767b3c4ec993e05639dc15050912f3be9e4bafa26f30438fcf05f

Contents?: true

Size: 1003 Bytes

Versions: 38

Compression:

Stored size: 1003 Bytes

Contents

module AmaLayout
  class Navigation
    include ActiveModel::Model
    include Draper::Decoratable

    attr_accessor :user, :current_url, :nav_file_path, :display_name

    def initialize(args = {})
      args = defaults.merge args
      super
    end

    cattr_accessor :member do
      "member"
    end
    cattr_accessor :non_member do
      "non-member"
    end
    cattr_accessor :member_in_renewal do
      "member-in-renewal"
    end
    cattr_accessor :member_in_renewal_late do
      "member-in-renewal-late"
    end

    def items
      navigation_items.fetch(user.try(:navigation), []).map do |n|
        NavigationItem.new n.merge({ current_url: current_url})
      end
    end

    def navigation_items
      YAML.load ERB.new(File.read nav_file_path).result
    end

    def email
      user.email
    end

  private

    def defaults
      {
        nav_file_path: File.join(Gem.loaded_specs["ama_layout"].full_gem_path, "lib", "ama_layout", "navigation.yml")
      }
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
ama_layout-5.4.0 lib/ama_layout/navigation.rb
ama_layout-5.2.0 lib/ama_layout/navigation.rb
ama_layout-5.1.1 lib/ama_layout/navigation.rb
ama_layout-5.1.0 lib/ama_layout/navigation.rb
ama_layout-5.0.2 lib/ama_layout/navigation.rb
ama_layout-5.0.1 lib/ama_layout/navigation.rb
ama_layout-5.0.0 lib/ama_layout/navigation.rb
ama_layout-4.10.1 lib/ama_layout/navigation.rb
ama_layout-4.10.0 lib/ama_layout/navigation.rb
ama_layout-4.9.0 lib/ama_layout/navigation.rb
ama_layout-4.8.7 lib/ama_layout/navigation.rb
ama_layout-4.8.6 lib/ama_layout/navigation.rb
ama_layout-4.8.5 lib/ama_layout/navigation.rb
ama_layout-4.8.4 lib/ama_layout/navigation.rb
ama_layout-4.8.3 lib/ama_layout/navigation.rb
ama_layout-4.8.2 lib/ama_layout/navigation.rb
ama_layout-4.8.1 lib/ama_layout/navigation.rb
ama_layout-4.8.0 lib/ama_layout/navigation.rb
ama_layout-4.7.1 lib/ama_layout/navigation.rb
ama_layout-4.7.0 lib/ama_layout/navigation.rb