Skip to content
Create a new class which inherits from a class it will replace.
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
spec
.gitignore
Gemfile
Gemfile.lock
LICENSE
README.md
subclass_and_replace.gemspec

README.md

Subclass and Replace

Create a new class which inherits from a class it will replace.

Description

Use this class when you need to replace a class method and still call the superclass method.

Documentation

Install

gem install subclass_and_replace

Example

Set defaults to Rails cookies without writing custom methods or changing core code.

subclass_and_replace ActionDispatch::Cookies::CookieJar do

  def handle_options(options)
    options[:httponly] = true if options[:httponly].nil?
  end

end
Something went wrong with that request. Please try again.