This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Symbol | |
def |(*args) | |
@args = args | |
self | |
end | |
def to_proc | |
Proc.new { |obj| | |
obj.send *[self] + (@args || []) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# best way to code: if event is nil, true, otherwise if event.user == user true, else false | |
# seems clear but is so vertically long for such a simple thing | |
if event | |
event.user == user | |
else | |
true | |
end | |
# nice and compact but wtf does it mean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I hear that aliasing lambda is bad, but this is | |
# much more readable... | |
def this_block(&block) | |
block | |
end | |
this_block{ @this.destroy }.should change(Thing, :count).by(-1) |