Sha256: ac008da21f5f3a44ead3e0767d31266410a1dc4735125a041a44122c08c388be

Contents?: true

Size: 528 Bytes

Versions: 2

Compression:

Stored size: 528 Bytes

Contents

class String
  # Takes in a hash and spits out the formatted string
  # Checks the delegate first
  def fill_url_params(params = {}, delegate = nil)
    params ||= {}
    split = self.split '/'
    split.collect { |path|
      ret = path
      if path[0] == ':'
        path_sym = path[1..-1].to_sym

        curr = nil
        if delegate && delegate.respond_to?(path_sym)
          curr = delegate.send(path_sym)
        end

        ret = (curr || params[path_sym] || path).to_s
      end

      ret
    }.join '/'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
motion-resource-0.0.2 lib/motion-resource/string.rb
motion-resource-0.0.1 lib/motion-resource/string.rb