lib/termvana/app/models/command.rb in termvana-0.2.0.beta2 vs lib/termvana/app/models/command.rb in termvana-0.2.0.beta3
- old
+ new
@@ -10,17 +10,23 @@
if !self.class.response || self.class.response == :none
respond_with :null
end
end
- def respond_with(opts = {})
- if opts == :null
- environment.send_message Termvana::Response.new
+ def respond_with(*args)
+ opts = args.extract_options!
+ opts[:message] ||= args.shift if args.first.is_a? String
+
+ if args.first == :null
+ opts = {}
elsif data = opts.delete(:text)
- environment.send_message Termvana::Response.new(:message => data)
+ opts[:message] ||= data
elsif data = opts.delete(:error)
- environment.send_message Termvana::Response.new(:message => data, :type => :error)
+ opts[:message] ||= data
+ opts[:type] = :error
end
+ opts[:type] ||= self.class.response
+ environment.send_message Termvana::Response.new(opts)
end
def self.type(arg = false)
@type = arg if arg