Skip to content

Instantly share code, notes, and snippets.

@AlexanderRD
Created August 31, 2015 12:43
Show Gist options
  • Save AlexanderRD/f8652f710097ca42e759 to your computer and use it in GitHub Desktop.
Save AlexanderRD/f8652f710097ca42e759 to your computer and use it in GitHub Desktop.
Credential adapter; wraps hash and converts keys into methods
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