lib/ralyxa/response_entities/response.rb in ralyxa-1.5.2 vs lib/ralyxa/response_entities/response.rb in ralyxa-1.6.0

- old
+ new

@@ -10,37 +10,38 @@ @start_over = start_over @card = card end def to_h - Hash.new.tap do |response| - set_version(response) - set_session_attributes(response) - set_response(response) + {}.tap do |response| + add_version(response) + add_session_attributes(response) + add_response(response) end end def self.as_hash(output_speech: Ralyxa::OutputSpeech.as_hash, session_attributes: {}, end_session: false, start_over: false, card: false) new(output_speech, session_attributes, end_session, start_over, card).to_h end private + attr_reader :response - def set_version(response) - response[:version] = "1.0" + def add_version(response) + response[:version] = '1.0' end - def set_session_attributes(response) + def add_session_attributes(response) return response[:sessionAttributes] = {} if @start_over response[:sessionAttributes] = @session_attributes unless @session_attributes.empty? end - def set_response(response) - response[:response] = Hash.new + def add_response(response) + response[:response] = {} response[:response][:outputSpeech] = @output_speech response[:response][:card] = @card if @card response[:response][:shouldEndSession] = @end_session end end end -end \ No newline at end of file +end