Permalink
Browse files

add Symbol#to_block

  • Loading branch information...
1 parent db273de commit 7748b8daf33f952f90fde950e995480a99d60a3e @bakkdoor committed Sep 10, 2012
Showing with 22 additions and 0 deletions.
  1. +13 −0 lib/symbol.fy
  2. +9 −0 tests/symbol.fy
View
@@ -52,4 +52,17 @@ class Symbol {
def to_sym {
self
}
+
+ def to_block {
+ """
+ @return @Block@ that sends @self as a message to its argument.
+
+ Example:
+ 'inspect to_block
+ # is equal to:
+ @{ inspect }
+ """
+
+ @{ receive_message: self }
+ }
}
View
@@ -32,4 +32,13 @@ FancySpec describe: Symbol with: {
'foo to_sym is: 'foo
'bar to_sym is: 'bar
}
+
+ it: "returns itself as a Block" with: 'to_block when: {
+ b = 'inspect to_block
+ b call: [2] . is: "2"
+ b call: ["foo"] . is: "\"foo\""
+
+ str = "hello, world yo!\"foo\""
+ b call: [str] . is: $ @{ inspect } call: [str]
+ }
}

0 comments on commit 7748b8d

Please sign in to comment.