Created
July 13, 2012 14:02
-
-
Save Irio/3105041 to your computer and use it in GitHub Desktop.
defining class methods
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
class SinglePages | |
file :about, %w(text) | |
class << self | |
# Generate write method to this file | |
def file(filename, attrs) | |
define_method "write_#{filename}" do |properties_hash| | |
puts properties_hash | |
end | |
end | |
end | |
end |
class SinglePages
class << self
def file(method_name, *args)
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def write_#{method_name}(*args)
args.each do |arg|
puts arg
end
end
RUBY
end
end
file :about, %w(teste)
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SinglePages.new.write_about('teste')