Skip to content

Instantly share code, notes, and snippets.

@jdlich
Created February 3, 2010 18:23
Show Gist options
  • Save jdlich/293851 to your computer and use it in GitHub Desktop.
Save jdlich/293851 to your computer and use it in GitHub Desktop.
class Home
require 'yaml'
def initialize item
@item = item
attributes = File.expand_path('content' + @item.identifier.gsub(/\/$/,'') + '.yaml')
attributes = File.open(attributes) { |a| YAML::load(a) }.keys
attributes.map do |attribute|
instance_variable_set("@#{attribute}", item[attribute.to_sym])
instance_eval %{
def #{attribute}
instance_variable_get("@#{attribute}")
end
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment