class Realm::Config

Public Instance Methods

persistence_gateway() click to toggle source
# File lib/realm/config.rb, line 29
def persistence_gateway
  return {} unless @persistence_gateway

  class_path = engine_path && "#{engine_path}/app/persistence/#{namespace}"
  repos_path = class_path && "#{class_path}/repositories"
  repos_module = "#{root_module}::Repositories"
  {
    root_module: root_module,
    class_path: class_path,
    repos_path: repos_path,
    repos_module: repos_module,
    migration_path: engine_path && "#{engine_path}/db/migrate",
    repositories: repositories(repos_path, repos_module),
  }.merge(@persistence_gateway)
end
plugins() click to toggle source
# File lib/realm/config.rb, line 25
def plugins
  Array(@plugins)
end

Private Instance Methods

repositories(repos_path, repos_module) click to toggle source
# File lib/realm/config.rb, line 47
def repositories(repos_path, repos_module)
  return [] unless repos_path

  Dir[File.join(repos_path, '**', '*.rb')].each_with_object([]) do |filename, all|
    matches = %r{^#{repos_path}/(.+)\.rb$}.match(filename)
    all << "#{repos_module}::#{matches[1].camelize}".constantize if matches
  end
end