Module: Forms::Tags::Responses
- Defined in:
- lib/forms/tags/responses.rb
Class Method Summary collapse
- .clear(tag) ⇒ Object
- .current(tag, request) ⇒ Object
-
.retrieve(source, key) ⇒ Object
Returns the value from a hash when in input key is sent.
Class Method Details
.clear(tag) ⇒ Object
50 51 52 |
# File 'lib/forms/tags/responses.rb', line 50 def clear(tag) tag.locals.response.update_attribute('result', nil) end |
.current(tag, request) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/forms/tags/responses.rb', line 7 def current(tag, request) response = nil if tag.locals.response.present? response = tag.locals.response elsif tag.locals.page.request.present? session = tag.locals.page.request.session[:form_response] begin response = Response.find(session) rescue if session == Object response = Response.create tag.locals.page.request.session[:form_response] = result.id end end end response end |
.retrieve(source, key) ⇒ Object
Returns the value from a hash when in input key is sent
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/forms/tags/responses.rb', line 29 def retrieve(source, key) result = nil if source.present? data = key.gsub("[","|").gsub("]","").split("|") if data.present? result = source.fetch(data[0].to_sym) data.delete_at(0) if data.length and result.present? data.each do |i| result = result.fetch(i.to_sym) rescue nil end end end end result end |