Last active
April 5, 2018 19:57
-
-
Save sheki/ed610e971b089218caca0c89bfbf7862 to your computer and use it in GitHub Desktop.
approximate.rb
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
class SuperActiveRecord < ActiveRecord | |
instance_methods.each |name| do .# not exact syntaxa | |
### IF THIS IS NOT POSSBILE override 10 most use actie record methods like | |
### new/find/where/find_by/update so on and so forth | |
original_method = instance_method(name) | |
define_method(name) do |*args| | |
check_if_allowed() | |
original_method.bind(self).call(*args)[[[[ | |
end | |
end | |
def check_if_allowed | |
if PRODUCTION.? | |
pass | |
end | |
callers = caller | |
check_if_caller_allowed() # by having a whitelist per-model | |
en | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment