Skip to content

Instantly share code, notes, and snippets.

@aportnov
Created July 6, 2009 01:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aportnov/141220 to your computer and use it in GitHub Desktop.
Save aportnov/141220 to your computer and use it in GitHub Desktop.
module Components
components_path = File.expand_path(File.dirname(__FILE__) + '/components')
files = Dir.new(components_path).select{|f| f =~ /.*\.rb/ } || []
files.each do |f|
body = File.new(File.join([components_path, f])).read
name = File.basename(f, '.rb').capitalize + "Helper"
module_eval <<-"end;"
module #{name}
#{body}
end
end;
Sinatra.helpers(const_get(name))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment