Sha256: 0dfbede62c62660dbdf429d1c815ed31ca4cf7cef7419a54b72196959d099a86

Contents?: true

Size: 1.2 KB

Versions: 43

Compression:

Stored size: 1.2 KB

Contents

class Object
  # Alias of <tt>to_s</tt>.
  def to_param
    to_s
  end
end

class NilClass
  # Returns +self+.
  def to_param
    self
  end
end

class TrueClass
  # Returns +self+.
  def to_param
    self
  end
end

class FalseClass
  # Returns +self+.
  def to_param
    self
  end
end

class Array
  # Calls <tt>to_param</tt> on all its elements and joins the result with
  # slashes. This is used by <tt>url_for</tt> in Action Pack.
  def to_param
    collect { |e| e.to_param }.join '/'
  end
end

class Hash
  # Returns a string representation of the receiver suitable for use as a URL
  # query string:
  #
  #   {name: 'David', nationality: 'Danish'}.to_param
  #   # => "name=David&nationality=Danish"
  #
  # An optional namespace can be passed to enclose the param names:
  #
  #   {name: 'David', nationality: 'Danish'}.to_param('user')
  #   # => "user[name]=David&user[nationality]=Danish"
  #
  # The string pairs "key=value" that conform the query string
  # are sorted lexicographically in ascending order.
  #
  # This method is also aliased as +to_query+.
  def to_param(namespace = nil)
    collect do |key, value|
      value.to_query(namespace ? "#{namespace}[#{key}]" : key)
    end.sort * '&'
  end
end

Version data entries

43 entries across 43 versions & 5 rubygems

Version Path
motion-support-1.1.0 motion/core_ext/object/to_param.rb
motion-support-1.0.0 motion/core_ext/object/to_param.rb
motion-support-0.3.0 motion/core_ext/object/to_param.rb
motion_blender-support-0.2.8 motion/core_ext/object/to_param.rb
motion_blender-support-0.2.7 motion/core_ext/object/to_param.rb
activesupport-4.0.9 lib/active_support/core_ext/object/to_param.rb
activesupport-4.0.8 lib/active_support/core_ext/object/to_param.rb
activesupport-4.0.7 lib/active_support/core_ext/object/to_param.rb
activesupport-4.0.6 lib/active_support/core_ext/object/to_param.rb
activesupport-4.0.6.rc3 lib/active_support/core_ext/object/to_param.rb
activesupport-4.0.6.rc2 lib/active_support/core_ext/object/to_param.rb
activesupport-4.0.6.rc1 lib/active_support/core_ext/object/to_param.rb
activesupport-4.0.5 lib/active_support/core_ext/object/to_param.rb
droiuby-0.3.6 lib/droiuby/support/object/to_param.rb
droiuby-0.3.5 lib/droiuby/support/object/to_param.rb
droiuby-0.3.4 lib/droiuby/support/object/to_param.rb
droiuby-0.3.3 lib/droiuby/support/object/to_param.rb
droiuby-0.3.2 lib/droiuby/support/object/to_param.rb
droiuby-0.3.1 lib/droiuby/support/object/to_param.rb
droiuby-0.3.0 lib/droiuby/support/object/to_param.rb