I have read this question, but I couldn't create a full example:
class Some
def method_a
puts "a"
end
def method_b
puts "b"
end
def method_c
puts "c"
end
end
some = Some.new
a = true
b = true
c = true
l = []
l << :method_a if a
l << :method_b if b
l << :method_c if c
l.inject(some) { |obj, method|
obj.send(method)
}
[demas @arch.local.net ][~/dev/study/ruby/oop]% ruby inject_ex.rb
ainject_ex.rb:26:in
block in <main>': undefined method
method_b' for nil:NilClass(NoMethodError)
from inject_ex.rb:26:in `each'
from inject_ex.rb:26:in `inject'
from inject_ex.rb:26:in `'