Skip to content

Instantly share code, notes, and snippets.

@zacclark
Created April 12, 2011 03:00
Show Gist options
  • Save zacclark/914841 to your computer and use it in GitHub Desktop.
Save zacclark/914841 to your computer and use it in GitHub Desktop.
First attempt at a simplified middleground record for exporting.
class FlatPerson
def initialize(person)
raise TypeMismatch unless person.class == Person
person.attribute_names.each do |attr|
eval("@#{attr} = person.#{attr}")
end
end
def method_missing(arg)
if eval("@#{arg}")
eval("@#{arg}")
end
end
end
class TypeMismatch < StandardError; end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment