rom-rb / rom

Data mapping and persistence toolkit for Ruby
https://rom-rb.org
MIT License
2.08k stars 161 forks source link

Improve Plugin API #535

Closed solnic closed 5 years ago

solnic commented 5 years ago

Plugin API hard-codes support for core components (relations, schemas, commands and mappers) and there's no way to register a new component. This means that external components, like changeset, repository or anything else that may exist, have no way to use the plugin API.

Examples

# register a new component in the Plugin API

# using default plugin type
ROM::Plugins.register(:repository)

# using a custom plugin type
ROM::Plugins.register(:repository, ROM::Repository::RepositoryPlugin)

# now we can do
ROM.plugins do
  adapter :sql do
    register :my_repo_plugin, MyRepoPlugin, type: :repository
  end
end