Skip to content

Instantly share code, notes, and snippets.

@roy
Created March 18, 2011 13:12
Show Gist options
  • Save roy/876042 to your computer and use it in GitHub Desktop.
Save roy/876042 to your computer and use it in GitHub Desktop.
module ProcessAsset
def self.included(base)
base.extend ClassMethods
end
module InstanceMethods
def process
self.send("#{asset_name}_file_name")
end
end
module ClassMethods
def process_asset(asset_name)
include InstanceMethods
define_method :asset_name do
"#{asset_name}"
end
end
end
end
class Person
include ProcessAsset
process_asset :photo
def photo_file_name
"testing.jpg"
end
end
p = Person.new
puts p.process #=> testing.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment