app/helpers/application_helper.rb
# TODO - come up with a great way to test this or extract it out in a couple objects or methods and test those
come up with a great way to test this or extract it out in a couple objects or methods and test those
come up with a great way to test this or extract it out in a couple objects or methods and test those
def expand_ids( data )
    return unless data
    data.gsub( /(^|\W)((#{Conversion.conversions.map{ |k,c| k.to_s }.join( '|' )})(\d+))(\W|$)/ ) do |match|
      conversion = Conversion.conversions[$3.to_sym]
      object = conversion.model.find_by_id( $4 )
      if object
        if conversion.link
          method = conversion.link.first
          options = {}
          conversion.link[1...conversion.link.size].each { |p| options[p] = object.send( p ) }
          url = send( "#{method}_path".to_sym, options )
          $1 + link_to( object.name, url ) + $5
        else
          link = $1 + object.name + $5
        end
      else
        match
      end
    end
  end
def expand_ids ( data ) return unless data data . gsub ( / (^| \W )(( #{ Conversion . conversions . map { | k , c | k . to_s } . join ( '|' ) } )( \d +))( \W |$) / ) do | match | conversion = Conversion . conversions [ $3 . to_sym ] object = conversion . model . find_by_id ( $4 ) if object if conversion . link method = conversion . link . first options = { } conversion . link [ 1 ... conversion . link . size ] . each { | p | options [ p ] = object . send ( p ) } url = send ( "#{method}_path" . to_sym , options ) $1 + link_to ( object . name , url ) + $5 else link = $1 + object . name + $5 end else match end end end
TODO - come up with a great way to test this or extract it out in a couple objects or methods and test those
TODO - come up with a great way to test this or extract it out in a couple objects or methods and test those
data
<not_specific>