Class: Pageflow::HelpEntries

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/pageflow/help_entries.rb

Instance Method Summary collapse

Constructor Details

#initializeHelpEntries

Returns a new instance of HelpEntries.



5
6
7
8
# File 'lib/pageflow/help_entries.rb', line 5

def initialize
  @help_entries = []
  @help_entries_by_name = {}
end

Instance Method Details

#each(&block) ⇒ Object



37
38
39
# File 'lib/pageflow/help_entries.rb', line 37

def each(&block)
  @help_entries.each(&block)
end

#flatObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
34
35
# File 'lib/pageflow/help_entries.rb', line 31

def flat
  map do |help_entry|
    [help_entry, help_entry.children]
  end.flatten
end

#register(name, options = {}) ⇒ Object

Add a section to the help dialog displayed in the editor.

Translation keys for the help entry are derived from its name by appending “.menu_item” and “.text”. Text is parsed as markdown.

Parameters:

  • name (String)

    Translation key prefix

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :parent (String)

    Name of the parent help entry

  • :priority (Fixnum) — default: 10

    Entries with higher priority come first in the entry list.



20
21
22
23
24
25
26
27
28
# File 'lib/pageflow/help_entries.rb', line 20

def register(name, options = {})
  help_entry = HelpEntry.new(name, options)
  @help_entries_by_name[name] = help_entry

  collection = find_collection(options[:parent])

  collection << help_entry
  collection.sort_by! { |help_entry| -help_entry.priority }
end