Permalink
Browse files

Use array instead of hash for calling out to fancy from ruby, as hash…

…es aren't necessarily ordered. :(
  • Loading branch information...
1 parent 4e3710b commit 598276690cfa4a49dc28a13a13c2bb7c07098369 @bakkdoor committed Mar 8, 2011
Showing with 18 additions and 4 deletions.
  1. +18 −4 ruby_lib/fancy.rb
View
22 ruby_lib/fancy.rb
@@ -15,11 +15,25 @@
Fancy::CodeLoader.load_compiled_file File.expand_path("../lib/eval", base)
class Object
- def fy(hash_or_name)
- if hash_or_name.is_a? Hash
- self.send("#{hash_or_name.keys.join(':')}:", *hash_or_name.values)
+ def fancy_message_args name_and_args
+ method_name = []
+ args = []
+ name_and_args.each_with_index do |a, i|
+ if i % 2 == 0
+ method_name << a
+ else
+ args << a
+ end
+ end
+ return [method_name.join(":") + ":", args]
+ end
+
+ def fy(*array_or_name)
+ if array_or_name.size > 1
+ message_name, args = fancy_message_args array_or_name
+ self.send(message_name, *args)
else
- self.send(":#{hash_or_name}")
+ self.send(":#{array_or_name}")
end
end

0 comments on commit 5982766

Please sign in to comment.