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
We have 2 classes 'ATypicalClass' and 'AnotherTypicalClass'
Both of those classes hold 4 instance and 4 singleton methods.
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
We tracked the overrides using the overrides_tracker gem.
We have 12 overrides within the codebase and 4 added methods.
Show build on overrides.ioThe GEM removes and changes some methods in both classes.
Now we only have 8 overrides within the codebase, but 8 added methods.
Show build on overrides.ioWe received an email letting us know about this changes happening.