class ROM::Rails::Railtie
Constants
- COMPONENT_DIRS
- MissingGatewayConfigError
Public Instance Methods
active_record?()
click to toggle source
@api private
# File lib/rom/rails/railtie.rb, line 134 def active_record? defined?(::ActiveRecord) end
auto_registration_paths()
click to toggle source
# File lib/rom/rails/railtie.rb, line 129 def auto_registration_paths config.rom.auto_registration_paths + [root] end
configure(&block)
click to toggle source
Behaves like `Railtie#configure` if the given block does not take any arguments. Otherwise yields the ROM
configuration to the block.
@example
ROM::Rails::Railtie.configure do |config| config.gateways[:default] = [:yaml, 'yaml:///data'] config.auto_registration_paths += [MyEngine.root] end
@api public
Calls superclass method
# File lib/rom/rails/railtie.rb, line 62 def configure(&block) config.rom = Configuration.new unless config.respond_to?(:rom) if block.arity == 1 block.call(config.rom) else super end end
configure_console_logger()
click to toggle source
@api private
# File lib/rom/rails/railtie.rb, line 144 def configure_console_logger return if active_record? || std_err_out_logger? console = ActiveSupport::Logger.new(STDERR) ::Rails.logger.extend ActiveSupport::Logger.broadcast console end
container()
click to toggle source
# File lib/rom/rails/railtie.rb, line 125 def container ROM.env end
create_configuration()
click to toggle source
# File lib/rom/rails/railtie.rb, line 72 def create_configuration ROM::Configuration.new(gateways) end
create_container()
click to toggle source
@api private
# File lib/rom/rails/railtie.rb, line 77 def create_container configuration = create_configuration auto_registration_paths.each do |root_path| configuration.auto_registration(::Rails.root.join(root_path), namespace: false) end ROM.container(configuration) end
disconnect()
click to toggle source
@api private
# File lib/rom/rails/railtie.rb, line 116 def disconnect container.disconnect unless container.nil? end
gateways()
click to toggle source
@api private
# File lib/rom/rails/railtie.rb, line 88 def gateways if active_record? load_active_record_config.each do |name, spec| config.rom.gateways[name] ||= [:sql, spec[:uri], spec[:options]] end end if config.rom.gateways.empty? ::Rails.logger.warn "It seems that you have not configured any gateways" config.rom.gateways[:default] = [ :memory, "memory://test" ] end config.rom.gateways end
load_active_record_config()
click to toggle source
Attempt to infer all configured gateways from activerecord
# File lib/rom/rails/railtie.rb, line 105 def load_active_record_config ROM::Rails::ActiveRecord::Configuration.new.call end
load_initializer()
click to toggle source
# File lib/rom/rails/railtie.rb, line 109 def load_initializer load "#{root}/config/initializers/rom.rb" rescue LoadError # do nothing end
root()
click to toggle source
@api private
# File lib/rom/rails/railtie.rb, line 121 def root ::Rails.root end
std_err_out_logger?()
click to toggle source
@api private
# File lib/rom/rails/railtie.rb, line 139 def std_err_out_logger? ActiveSupport::Logger.logger_outputs_to?(::Rails.logger, STDERR, STDOUT) end