Inject
Inject arguments into methods, by name.
Inspired by ideas from Raptor and Objectify. Figured something like this might be useful on its own.
Example
class InsultParams
def target
"Arthur Philip Dent"
end
def insult
"You're a jerk, Dent... a complete kneebiter."
end
end
class Wowbagger
def self.vilify(target, insult)
[target, insult].join(": ")
end
end
injector = Inject::Injector.new(InsultParams.new)
injector.call(Wowbagger, :vilify)
# => "Arthur Philip Dent: You're a jerk, Dent... a complete kneebiter."