lib/sugar-high/alias.rb in sugar-high-0.1.2 vs lib/sugar-high/alias.rb in sugar-high-0.1.4

- old
+ new

@@ -1,6 +1,7 @@ require 'sugar-high/methods' +require 'sugar-high/hash' class Module # multi_alias name, :create => :new, :insert_into => [:inject_into, :update], :read => :X_content # :options => :after @@ -28,23 +29,26 @@ raise ArgumentError, "Name of method pattern to alias not specified. Please pass name as either first argument or as :before or :after option" if !name options.delete(:_after_) options.delete(:_before_) + direction = options.delete(:_direction_) + options = options.hash_revert if direction == :reverse + options.each_pair do |original, aliases| alias_methods name.to_sym, original, [aliases].flatten, config_options end end def alias_methods name, original, aliases, config_options aliases.each do |alias_name| new_alias = make_name(name, alias_name.to_s, config_options) original_name = make_name(name, original.to_s, config_options) - begin + begin alias_method new_alias, original_name rescue - raise ArgumentError, "Error creaing alias for ##{original_name} with #{new_alias}" + raise ArgumentError, "Error creating alias for ##{original_name} with ##{new_alias}" end end end protected \ No newline at end of file