Sha256: 7fa47f9684a68d8d571448435a0d24ff7adb2cdb2cf231ae2bb60d98164d41b5

Contents?: true

Size: 481 Bytes

Versions: 3

Compression:

Stored size: 481 Bytes

Contents

module Termvana
  class Request
    include Virtus
    attribute :full_command, String
    attribute :type, Symbol, :default => :standard
    def initialize(*args)
      if args.first.is_a? String
        command = JSON.parse(args.first).symbolize_keys
        super(command)
      else
        super(*args)
      end
    end

    def [](*args)
      @tokens ||= Shellwords.split(full_command)
      @tokens[*args]
    end

    def to_s
      attributes.to_json
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
termvana-0.2.0.beta3 lib/termvana/app/models/request.rb
termvana-0.2.0.beta2 lib/termvana/app/models/request.rb
termvana-0.2.0.beta1 lib/termvana/app/models/request.rb