class Warp::Dir::App::Response

Constants

ERROR
INFO
RETURN_TYPE
SHELL

Attributes

config[RW]
messages[RW]

Public Class Methods

configure(&block) click to toggle source
# File lib/warp/dir/app/response.rb, line 81
def self.configure(&block)
  self.instance.configure(&block)
end
new() click to toggle source
# File lib/warp/dir/app/response.rb, line 59
def initialize
  @messages = []
end

Public Instance Methods

code(value = nil) click to toggle source
# File lib/warp/dir/app/response.rb, line 104
def code(value = nil)
  if value
    @type.exit_code = value
    self
  else
    @type.exit_code
  end
end
configure(&block) click to toggle source

Configure & Accessors

# File lib/warp/dir/app/response.rb, line 76
def configure(&block)
  self.instance_eval(&block)
  self
end
exit!() click to toggle source
# File lib/warp/dir/app/response.rb, line 70
def exit!
  raise ::ArgumentError.new('No type defined for Response object') unless @type
  system_exit!(@type.exit_code)
end
exit_code=(value) click to toggle source

can’t change exit code in SHELL

# File lib/warp/dir/app/response.rb, line 47
def exit_code=(value)
end
inspect() click to toggle source
# File lib/warp/dir/app/response.rb, line 113
def inspect
  "#{self.class.name}={#{type.inspect}, #{messages.inspect}}"
end
message(message = nil) click to toggle source
# File lib/warp/dir/app/response.rb, line 85
def message(message = nil)
  if message
    @messages << message
    self
  else
    @messages.join
  end
end
print(msg) click to toggle source
to_s() click to toggle source
# File lib/warp/dir/app/response.rb, line 117
def to_s
  "AppResponse[type: {#{type}}, messages: '#{messages.join(' ')}']"
end
type(a_type = nil) click to toggle source
# File lib/warp/dir/app/response.rb, line 94
def type(a_type = nil)
  if a_type
    @type = a_type.kind_of?(Warp::Dir::App::Response::Type) ? a_type : RETURN_TYPE[a_type]
    raise(::ArgumentError.new("Can't find response type #{a_type} #{@type}")) unless @type
    self
  else
    @type
  end
end

Private Instance Methods

system_exit!(code) click to toggle source
# File lib/warp/dir/app/response.rb, line 123
def system_exit!(code)
  Kernel.exit(code) unless self.class.instance_variable_defined?(:@exit_disabled) && self.class.exit_disabled?
  self
end