Last active
July 24, 2019 15:12
-
-
Save crazymykl/4615e205ae812227a9245dd131ff80f1 to your computer and use it in GitHub Desktop.
Flagged base class
This file contains 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
# This works because the first constant classes are assigned to automagically becomes their main name | |
ApplicationRecord = if feature_flag? | |
Class.new(ActiveRecord::Base) do | |
# implementation | |
end | |
else | |
ActiveRecord::Base | |
end | |
=begin | |
[20] pry(main)> def feature_flag?; false; end | |
[21] pry(main)> class Quux < ApplicationRecord; end | |
=> nil | |
[22] pry(main)> Quux.superclass | |
=> ActiveRecord::Base | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment