Step by Step Example

This is an example of how Overrides.io works on a simple Ruby on Rails application. The application basically just consists of two classes that are adding and overriding some methods of an ordinary gem.

View the application's overrides on Overrides.io

View the application source code on GitHub
View the ordinary_gems source code on GitHub


1. Let's look at the ordinary gem first

We have 2 classes 'ATypicalClass' and 'AnotherTypicalClass'

Both of those classes hold 4 instance and 4 singleton methods.

  • self.a_singleton_method_that_we_do_not_override
  • self.a_singleton_method_that_that_stays_the_same
  • self.a_singleton_method_that_will_change
  • self.a_singleton_method_that_will_be_removed
  • a_instance_method_that_we_do_not_override
  • a_instance_method_that_that_stays_the_same
  • a_instance_method_that_will_change
  • a_instance_method_that_will_be_removed

2. In our application we override six of those eight methods in both classes.

We do this by a 'class_eval()' and a 'prepend' implementation.

module OrdinaryGem
  module ATypicalClassDecorator
    module InstanceMethods
      def a_singleton_method_that_stays_the_same
        "This is our override of a simple singleton method."
        "This method should stay the same in the next version."
      end

      def a_singleton_method_that_will_change         "This is our override of a simple singleton method."         "This method will be rewritten in the next version."       end
      def a_singleton_method_that_will_be_removed         "This is our override of a simple instance method."         "This method will be removed in the next version."       end
      def a_singleton_method_that_we_have_added         "This is our custom singleton method."         "This is not an override."       end     end
    def self.prepended(base)       base.singleton_class.prepend(InstanceMethods)     end
    def a_instance_method_that_that_stays_the_same       "This is our override of a simple instance method."       "This method should stay the same in the next version."     end
    def a_instance_method_that_will_change       "This is our override of a simple instance method."       "This method will be rewritten in the next version."     end
    def a_instance_method_that_will_be_removed       "This is our override of a simple instance method."       "This method will be removed in the next version."     end
    def a_instance_method_that_we_have_added       "This is our custom instance method."       "This is not an override."     end   end end OrdinaryGem::ATypicalClass.prepend OrdinaryGem::ATypicalClassDecorator
OrdinaryGem::AnotherTypicalClass.class_eval do
  def self.a_singleton_method_that_stays_the_same
    "This is our override of a simple singleton method."
    "This method should stay the same in the next version."
  end

  def self.a_singleton_method_that_will_change     "This is our override of a simple singleton method."     "This method will be rewritten in the next version."   end
  def self.a_singleton_method_that_will_be_removed     "This is our override of a simple instance method."     "This method will be removed in the next version."   end
  def self.a_singleton_method_that_we_have_added     "This is our custom singleton method."     "This is not an override."   end
  def a_instance_method_that_that_stays_the_same     "This is our override of a simple instance method."     "This method should stay the same in the next version."   end
  def a_instance_method_that_will_change     "This is our override of a simple instance method."     "This method will be rewritten in the next version."   end
  def a_instance_method_that_will_be_removed     "This is our override of a simple instance method."     "This method will be removed in the next version."   end
  def a_instance_method_that_we_have_added     "This is our custom instance method."     "This is not an override."   end
 end

3. Let's look how this looks on overrides.io

We tracked the overrides using the overrides_tracker gem.

We have 12 overrides within the codebase and 4 added methods.

Show build on overrides.io

4. Now let's assume we upgrade the ordinary gem

The GEM removes and changes some methods in both classes.

  • self.a_singleton_method_that_we_do_not_override: Stayed the same
  • self.a_singleton_method_that_that_stays_the_same: Stayed the same
  • self.a_singleton_method_tthat_will_change: Got changed
  • self.a_singleton_method_that_will_be_removed: Got changed
  • a_instance_method_that_we_do_not_override: Stayed the same
  • a_instance_method_that_that_stays_the_same: Stayed the same
  • a_instance_method_that_will_change: Got changed
  • a_instance_method_that_will_be_removed: Got changed

5. Let's look again how this looks on overrides.io

Now we only have 8 overrides within the codebase, but 8 added methods.

Show build on overrides.io

6. How come?

We received an email letting us know about this changes happening.


7. Finally: Let's look at the detailed comparison

Show detailed comparison
We need to use cookies in order for you to log in to Overrides.io. By continuing to use the website you agree to the use of cookies. If you would like to know more about how we use your information, we recommend that you read our privacy policy.