lib/vedeu/support/keymap_validator.rb in vedeu-0.2.2 vs lib/vedeu/support/keymap_validator.rb in vedeu-0.2.3

- old
+ new

@@ -27,31 +27,30 @@ # @return [KeymapValidator] def initialize(storage, key, interface = '') @storage, @key, @interface = storage, key, interface end + # @raise [KeyInUse] When the key is already in use. # @see KeymapValidator.check def check if system_key?(key) - [false, fail_message(key) + ' by the system.'] + fail KeyInUse, "'#{key}' is already in use by the system." elsif global_key?(key) - [false, fail_message(key) + ' as a global key.'] + fail KeyInUse, "'#{key}' is already in use as a global key." elsif interface_key?(key, interface) if defined_value?(interface) - [false, fail_message(key) + ' by this interface.'] + fail KeyInUse, "'#{key}' is already in use by this interface." else - [false, fail_message(key) + ' by another interface and therefore ' \ - 'cannot be global.'] + fail KeyInUse, "'#{key}' is already in use and cannot be global." end - else - [true, 'Key can be registered.'] - end + + true end private attr_reader :storage, :key, :interface @@ -94,12 +93,8 @@ # @return [Boolean] def system_key?(key) Configuration.system_keys.values.include?(key) end - def fail_message(key) - "Cannot register key '#{key.to_s}' as already in use" - end + end # KeymapValidator - end - -end +end # Vedeu