Last active
September 22, 2015 11:56
-
-
Save avdgaag/c66ad5868d8e699dd639 to your computer and use it in GitHub Desktop.
Example setup API for ROM::Lotus
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
# Lotus has different applications in a single project, optionally with different configurations and/or mappings. | |
# ROM::Lotus should/could conigure a different setup per application, rather than a single global setup. | |
# Relations could be global (defined in ./lib) while mappings might live in both (./apps/web/ and ./lib). | |
# This would resemble how Lotus::Model is organised. | |
# | |
# The only problem here is that Lotus has no hooks for loading framework (it's all hard-coded)s, and | |
# therefore we can't easily extend the application load process with our custom setup code without | |
# resorting to monkeypatching. | |
# apps/web/application.rb | |
module Web | |
class Application < Lotus::Application | |
configure do | |
rom.setup do |setup| | |
setup.adapter [:sql, ENV['WEB_DATABASE_URL']] | |
end | |
end | |
end | |
end | |
# lib/demo.rb | |
require 'rom-lotus' | |
ROM::Lotus.setup do |setup| | |
setup.adapter [:sql, ENV['DEMO_DATABASE_URL']] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment