Created
November 13, 2014 21:00
-
-
Save justincampbell/2a39e6791a9fb5a56ee7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "About to define BaseService" | |
class BaseService | |
puts "BaseService code running" | |
def self.clone; puts "clone called"; super; end | |
def self.dup; puts "dup called"; super; end | |
end | |
puts "About to inherit from BaseService" | |
class MyService < BaseService | |
puts "MyService code running" | |
end | |
class AnotherService | |
def self.new(*args) | |
obj = allocate | |
obj.send(:initialize, *args) | |
obj | |
end | |
def self.allocate | |
puts "Allocate called" | |
super | |
end | |
def initialize | |
end | |
end | |
AnotherService.new # => #<AnotherService:0x007f959a9d9d10> | |
# >> About to define BaseService | |
# >> BaseService code running | |
# >> About to inherit from BaseService | |
# >> MyService code running | |
# >> Allocate called |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment