As I was looking to implement the new Spaces feature (see forem/forem#16842), I began looking at how to adjust the admin menu. I found the Menu and AdminMenu. I wanted to add the "spaces" item under the `:content_manager` scope. Looking at the implementation, I saw I would need some additional branching logic. To get an understanding of the implementation, I chose factor towards classes. This refactor does a few things: 1) Clarifies a method name (e.g. "children?" becomes "has_multiple_children?") 2) Adds some tests of the menu implementation. 3) Removes deeply nested hashs in favor of first class objects. 4) Removes a complex method for determining menu visibility, instead favoring a method that either takes a boolean OR a lambda. There are further refactors to consider, especially in regards to the helper methods and some of the coercion of strings into different formats. But this refactor gets me the part I most am interested in: Making it easier to specify a menu item as visible or not. |
||
|---|---|---|
| .. | ||
| acts_as_taggable_on | ||
| constants | ||
| honeycomb | ||
| middlewares | ||
| redcarpet/render | ||
| reverse_markdown/converters | ||
| api_constraints.rb | ||
| app_secrets.rb | ||
| black_box.rb | ||
| html_css_to_image.rb | ||
| menu.rb | ||
| rails_env_constraint.rb | ||
| release_phase_notifier.rb | ||
| seeder.rb | ||
| string_attribute_cleaner.rb | ||
| throttled_call.rb | ||
| url.rb | ||