Skip to content

Instantly share code, notes, and snippets.

@christopherslee
Last active December 17, 2015 00:29
Show Gist options
  • Save christopherslee/5521596 to your computer and use it in GitHub Desktop.
Save christopherslee/5521596 to your computer and use it in GitHub Desktop.
Introduction to Metaprogramming: Lesson 1
class Customer
attr_reader :id, :datasource
def initialize(id, datasource)
@id = id
@datasource = datasource
end
def first
value = datasource.get_first_value(id)
"First: #{value}"
end
def last
value = datasource.get_last_value(id)
"Last: #{value}"
end
def email
value = datasource.get_email_value(id)
"Email: #{value}"
end
def age
value = datasource.get_age_value(id)
"Age: #{value}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment