lib/vedeu/api/menu.rb in vedeu-0.2.2 vs lib/vedeu/api/menu.rb in vedeu-0.2.3
- old
+ new
@@ -1,6 +1,7 @@
module Vedeu
+
module API
# Provides the mechanism to create menus within client applications and use
# events to drive them.
#
@@ -25,20 +26,19 @@
def initialize(attributes = {})
@attributes = defaults.merge!(attributes)
end
# @param block [Proc]
+ # @raise [InvalidSyntax] When the required block is not given.
# @return [API::Menu]
def define(&block)
fail InvalidSyntax, '`menu` requires a block.' unless block_given?
@self_before_instance_eval = eval('self', block.binding)
instance_eval(&block)
- validate_attributes!
-
Vedeu::Menus.add(attributes)
self
end
@@ -46,11 +46,10 @@
# model classes.
#
# In the 'my_playlist' example below, your `Track` model may return a
# collection of tracks to populate the menu.
#
- # @api public
# @param collection [Array]
#
# @example
# menu 'my_menu' do
# items [:item_1, :item_2, :item_3]
@@ -66,11 +65,10 @@
end
# The name of the menu. Used to reference the menu throughout your
# application's execution lifetime.
#
- # @api public
# @param value [String]
#
# @example
# menu do
# name 'my_menu'
@@ -92,24 +90,18 @@
name: '',
items: []
}
end
- # At present, validates that a menu has a name attribute.
- #
# @api private
- # @return [Boolean]
- def validate_attributes!
- unless defined_value?(attributes[:name])
- fail InvalidSyntax, 'Menus must have a `name`.'
- end
- end
-
- # @api private
# @return []
def method_missing(method, *args, &block)
+ Vedeu.log("API::Menu#method_missing '#{method.to_s}' (args: #{args.inspect})")
+
@self_before_instance_eval.send(method, *args, &block)
end
- end
- end
-end
+ end # Menu
+
+ end # API
+
+end # Vedeu