lib/menu_builder/controller.rb in menu_builder-0.4.4 vs lib/menu_builder/controller.rb in menu_builder-0.5
- old
+ new
@@ -1,23 +1,31 @@
module MenuBuilder
module Controller
extend ActiveSupport::Concern
def menu_items(*items)
- instance_variable_set('@menu_items', items)
+ @menu_items = items
end
alias_method :menu_item, :menu_items
+ def append_menu_items(*items)
+ @menu_items += items
+ end
+ alias_method :append_menu_item, :append_menu_items
+
+ def prepend_menu_items(*items)
+ @menu_items = items + @menu_items
+ end
+ alias_method :prepend_menu_item, :prepend_menu_items
+
module ClassMethods
def menu_items(*items)
options = items.extract_options!
before_action(options) do |controller|
- controller.instance_variable_set('@menu_items', items)
+ controller.instance_variable_set("@menu_items", items)
end
end
alias_method :menu_item, :menu_items
-
end
-
end
end