Class: Pageflow::HelpEntries
- Inherits:
-
Object
- Object
- Pageflow::HelpEntries
- Includes:
- Enumerable
- Defined in:
- lib/pageflow/help_entries.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #flat ⇒ Object private
-
#initialize ⇒ HelpEntries
constructor
A new instance of HelpEntries.
-
#register(name, options = {}) ⇒ Object
Add a section to the help dialog displayed in the editor.
Constructor Details
#initialize ⇒ HelpEntries
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 |
#flat ⇒ Object
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.
20 21 22 23 24 25 26 27 28 |
# File 'lib/pageflow/help_entries.rb', line 20 def register(name, = {}) help_entry = HelpEntry.new(name, ) @help_entries_by_name[name] = help_entry collection = find_collection([:parent]) collection << help_entry collection.sort_by! { |help_entry| -help_entry.priority } end |