Issue:
I am using a global constant STORE_DATA_ENABLED to enable a module I wrote (StoreData):
Example:
STORE_DATA_ENABLED = false
...
module StoreData
def a
return unless STORE_DATA_ENABLED
...
end
def b
return unless STORE_DATA_ENABLED
...
end
def c
return unless STORE_DATA_ENABLED
...
end
...
end
I think there is a way to disable the module without checking all the methods in the module.
Any Ideas to DRY this code ?
Use a
before_filter. This is called before every method call in your module:EDIT: a ruby-only approach. This uses the module initializer to re-create all public methods in the module and make them return
nil. I did not try how this behaves when you have arguments in your methods.