Skip to content

Instantly share code, notes, and snippets.

@j-mcnally
Last active August 29, 2015 14:00
Show Gist options
  • Select an option

  • Save j-mcnally/11388951 to your computer and use it in GitHub Desktop.

Select an option

Save j-mcnally/11388951 to your computer and use it in GitHub Desktop.
require 'reward/starbucks'
require 'reward/united'
class Card
def initialize(params)
@type = params[:type]
@username = params[:username]
@password = params[:password]
end
def my_klass
@klass ||= Object.const_get(@type.capitalize) if Object.const_defined?(@type.capitalize)
end
def reward_balance
my_klass.try(:card_balance, @username, @password)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment