Created
August 31, 2015 12:43
-
-
Save AlexanderRD/f8652f710097ca42e759 to your computer and use it in GitHub Desktop.
Credential adapter; wraps hash and converts keys into methods
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
module Patterns | |
class CredentialAdapter | |
attr_reader :config_params | |
def initialize(config_params ={}) | |
@config_params = config_params | |
end | |
def method_missing(message, *args, &block) | |
if config_params.include?(message) | |
config_params[message] | |
else | |
nil | |
end | |
end | |
def respond_to?(method_name, include_private = false) | |
config_params.include?(method_name) || super | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment