Sha256: 63d1a43ae98505e3a28f8f42b227b014ac432806f71834c2290adede34cd78ef

Contents?: true

Size: 741 Bytes

Versions: 4

Compression:

Stored size: 741 Bytes

Contents

module Vedeu
  class Command
    attr_accessor :id, :attributes, :name, :klass, :keyword, :keypress

    class << self
      def create(attributes = {})
        new(attributes).create
      end
    end

    def initialize(attributes = {})
      @attributes = attributes || {}
      @name       = attributes[:name]
      @klass      = attributes[:klass]
      @keyword    = attributes.fetch(:options, {}).fetch(:keyword, "")
      @keypress   = attributes.fetch(:options, {}).fetch(:keypress, "")
    end

    def create
      CommandRepository.create(self)
      self
    end

    def execute(args = [])
      executable.call(*args)
    end

    def executable
      Proc.new { |*args| attributes[:klass].dispatch(*args) }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vedeu-0.0.14 lib/vedeu/repository/command.rb
vedeu-0.0.13 lib/vedeu/repository/command.rb
vedeu-0.0.12 lib/vedeu/repository/command.rb
vedeu-0.0.11 lib/vedeu/repository/command.rb