-
-
Save daxhuiberts/876053 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ProcessAsset | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def process_asset(asset_name) | |
define_method :process do | |
send "#{asset_name}_file_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