Sha256: 3fac0b533dbb09c3d1e9a5c5e6f31a3603cf453d1f46fcb73853b540fbf64a24

Contents?: true

Size: 785 Bytes

Versions: 44

Compression:

Stored size: 785 Bytes

Contents

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

    attr_accessor :user, :current_url

    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

  private
    def navigation_items
      file = File.join Gem.loaded_specs["ama_layout"].full_gem_path, "lib", "ama_layout", "navigation.yml"
      YAML.load ERB.new(File.read file).result
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
ama_layout-1.1.20 lib/ama_layout/navigation.rb
ama_layout-1.1.15 lib/ama_layout/navigation.rb
ama_layout-1.1.14 lib/ama_layout/navigation.rb
ama_layout-1.1.13 lib/ama_layout/navigation.rb