class Commander attr_accessor :command def initialize(&block) @command = block end def on_button_push @command.call if @command endendnew_button = Commander.new do puts "asdf"end