Q:

Quitting method chain execution early

Here's some simple Ruby code:
class Foo
  def initialize(args)
    @data = args[:data]
  end

  def perform
    quit_if_no_data
    print_message
  end

  def quit_if_no_data
    return unless @data
  end

  def print_message
    puts "You've got the data, congrats!"
  end
end

Foo.new({}).perform # want nil to be returned

How do I quit from the method chain execution with nil returned if the object is instantiated without data? I'd like Foo.new({}).perform to return nil.

A:

In this situation you probably want to raise an exception in the constructor if a required argument isn't supplied.
If the argument is actually optional, you need to slightly rethink how you're structuring you program. You should drop the quit_if_ prefix, that's never going to work, and its not supposed to work. You can't invent new forms of program flow that way. There is no way you can (or should) be able to jump out of a method that way. If you want to, you need to be more explicit with a raise or throw and a rescue/catch.
The way to do this properly is for your quit_if_no_data method to actually be called should_quit? and simply return true/false, indicating whether you should quit, and then conditionally quit from the calling method:
  def perform
    return if should_quit?
    print_message
  end

  def should_quit?
    @data == nil
  end

Because Ruby is Ruby, you can make something that works similarly to what you're trying to do with a proc, but it's an extremely overwrought solution to your problem, so don't do this:
 def perform
   with_data do
     print_message
   end
 end

 def with_data
   yield if @data
 end

