Sha256: a4b552dc9f914a482344494a781f8873d84037d25b8156b2416b6ed2fe703cac

Contents?: true

Size: 1.15 KB

Versions: 270

Compression:

Stored size: 1.15 KB

Contents

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

class NilClass
  def to_param
    self
  end
end

class TrueClass
  def to_param
    self
  end
end

class FalseClass
  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

270 entries across 226 versions & 25 rubygems

Version Path
activesupport-3.2.10 lib/active_support/core_ext/object/to_param.rb
activesupport-3.1.9 lib/active_support/core_ext/object/to_param.rb
classiccms-0.6.9 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/object/to_param.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.3/vendor/bundle/gems/jquery_regex-0.0.2/vendor/bundle/gems/activesupport-3.2.9/lib/active_support/core_ext/object/to_param.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.3/vendor/bundle/gems/jquery_regex-0.0.2/vendor/bundle/gems/jquery_regex-0.0.1/vendor/bundle/gems/activesupport-3.2.9/lib/active_support/core_ext/object/to_param.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.2/vendor/bundle/gems/jquery_regex-0.0.1/vendor/bundle/gems/activesupport-3.2.9/lib/active_support/core_ext/object/to_param.rb
jquery_regex-0.0.3 vendor/bundle/gems/activesupport-3.2.9/lib/active_support/core_ext/object/to_param.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.1/vendor/bundle/gems/activesupport-3.2.9/lib/active_support/core_ext/object/to_param.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.3/vendor/bundle/gems/activesupport-3.2.9/lib/active_support/core_ext/object/to_param.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.2/vendor/bundle/gems/activesupport-3.2.9/lib/active_support/core_ext/object/to_param.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.3/vendor/bundle/gems/jquery_regex-0.0.1/vendor/bundle/gems/activesupport-3.2.9/lib/active_support/core_ext/object/to_param.rb
jquery_regex-0.0.1 vendor/bundle/gems/activesupport-3.2.9/lib/active_support/core_ext/object/to_param.rb
dirty_history-0.7.3 dirty_history/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/core_ext/object/to_param.rb
dirty_history-0.7.2 dirty_history/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/core_ext/object/to_param.rb
dirty_history-0.7.1 dirty_history/ruby/1.9.1/gems/activesupport-3.1.1/lib/active_support/core_ext/object/to_param.rb
challah-rolls-0.2.0 vendor/bundle/gems/activesupport-3.2.8/lib/active_support/core_ext/object/to_param.rb
challah-rolls-0.2.0 vendor/bundle/gems/activesupport-3.2.7/lib/active_support/core_ext/object/to_param.rb
challah-rolls-0.2.0 vendor/bundle/gems/activesupport-3.2.9/lib/active_support/core_ext/object/to_param.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/activesupport-3.2.7/lib/active_support/core_ext/object/to_param.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/activesupport-3.2.9/lib/active_support/core_ext/object/to_param.rb