You can simplify slightly:
def ipsum
data = get_data
data.each { |id| yield dolor(id) } if block_given?
data
end
Taking advantage of the fact that Array#each
returns the array, this is arguably even simpler, but I'm not sure I like it:
def ipsum
return get_data unless block_given?
get_data.each { |id| yield dolor(id) }
end