Mega Code Archive

 
Categories / Ruby / Design Patterns
 

An Easier Way of Command Pattern

class Commander   attr_accessor :command   def initialize(command)     @command = command   end   def on_button_push     @command.execute if @command   end end class YourCommand   def execute   end end save_button = Commander.new( YourCommand.new )