xml地图|网站地图|网站标签 [设为首页] [加入收藏]

An Easier Way of Command Pattern

来源:http://www.ccidsi.com 作者:最新解决方案 人气:128 发布时间:2019-06-19
摘要:class Commander attr_accessor :command def initialize(command) @command = command end def on_button_push @command.execute if @command endendclass YourCommand def execute endendsave_button = Commander.new( YourCommand.new )
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 )

本文由68399皇家赌场发布于最新解决方案,转载请注明出处:An Easier Way of Command Pattern

关键词: 68399皇家赌场 设计模式 Ruby

最火资讯