Sha256: 5a955a2cf82bf0d7ab083f5836b04fca976388f33d8883261160c948b54fc102
Contents?: true
Size: 1.25 KB
Versions: 17
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true module Decidim # # This class handles all logic regarding registering menus # class MenuRegistry class << self # # Finds a menu by name or creates it if it does not exist. Optionally, # registers a MenuItem DSL block for the menu. # # @param name [Symbol] Name of the menu # @param &block [Menu] Registration body of the menu. It is stored to be # evaluated at rendering time # def register(name, &block) menu = find(name) || create(name) menu.configurations << block menu end # # Finds a menu by name # # @param name [Symbol] The name of the menu # def find(name) all[name] end # # Creates an empty named menu # # @param name [Symbol] The name of the menu # def create(name) all[name] = new end # # Destroys a named menu # # @param name [Symbol] The name of the menu # def destroy(name) all[name] = nil end private def all @all ||= {} end end attr_reader :configurations def initialize @configurations = [] end end end
Version data entries
17 entries across 17 versions & 1 rubygems