Module: GBDev::CallbackLogger::HelperMethods
- Defined in:
- lib/callback_logger/logger_link_to.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#callback_logger_link_to(app_log_object) ⇒ Object
:nodoc:
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/callback_logger/logger_link_to.rb', line 10 def callback_logger_link_to(app_log_object) # TODO: add object checker stuff here.... # Get model updated in the transaction model = ActiveSupport::Inflector.camelize(app_log_object.model).constantize # obj = model.find(obj_id) return app_log_object.msg if model.callback_logger_object_url.blank? # Get stuff within parentheses. It will be the second match. regex = Regexp.new('\((.+)\)$') matches = regex.match(app_log_object.msg) return app_log_object.msg if matches.nil? # matches[1] contains the content within the parentheses. content = matches[1] # Get the id for this entry regex = Regexp.new('^id\|\|(\d+)\|\|') # String: id||176028860||176028860|::|updated_at||.... matches = regex.match(app_log_object.data) return app_log_object.msg if matches.nil? # matches[1] contains the content within the parentheses. obj_id = matches[1] # Add the id to the url. There should probably be a # check whether or not to include it. # TODO: .... model.callback_logger_object_url.merge!({:id => obj_id}) app_log_object.msg.gsub(content, link_to(content, model.callback_logger_object_url)) end |