I see at least two approaches:
1) You seem to like to write lambdas with an implicit receiver (I wouldn't recommend it, self
obviously changes), you have instance_exec for that:
transform = -> { reverse.map(&:upcase) }
["a", "b", "c"].instance_exec(&transform)
#=> ["C", "B", "A"]
2) Write a custom extension, for example Object#apply
:
class Object
def apply(block, *args)
block.call(self, *args)
end
end
transform = -> strings { strings.reverse.map(&:upcase) }
["a", "b", "c"].apply(transform)
#=> ["C", "B", "A"]