title: Is it possible to do a before_action in Ruby (like in Rails)?
body: <p>Is it possible to call a <code>before_action</code> before some specified method like in rails?</p>
  
  <pre><code>class Calculator
    before_action { raise Exception, "calculator is empty" if @numbers.nil? }, 
                   only: [:plus, :minus, :divide, :times]
  
    def push number
      @numbers ||= [] 
      @numbers &lt;&lt; number
    end
  
    def plus
      # ... 
    end
  
    def minus
      # ... 
    end
  
    def divide
      # ... 
    end
  
    def times
      # ... 
    end
  
      # ... 
  end
  </code></pre>