Class: ForestAdminDatasourceMambuPayments::Plugins::Relations::OneToManyLinkPlugin
- Inherits:
-
ForestAdminDatasourceCustomizer::Plugins::Plugin
- Object
- ForestAdminDatasourceCustomizer::Plugins::Plugin
- ForestAdminDatasourceMambuPayments::Plugins::Relations::OneToManyLinkPlugin
- Defined in:
- lib/forest_admin_datasource_mambu_payments/plugins/relations/one_to_many_link_plugin.rb
Overview
Base for the “simple” reciprocal OneToMany links: the target already carries a native foreign key, so the plugin only declares the relation on the host. Subclasses configure it declaratively:
class LinkExternalAccountToIncomingPayments < OneToManyLinkPlugin
link host: 'MambuExternalAccount', to: 'MambuIncomingPayment',
name: 'incoming_payments', origin_key: 'external_account_id'
end
Install at the datasource level: @agent.use(plugin, {}).
Direct Known Subclasses
LinkExternalAccountToDirectDebitMandates, LinkExternalAccountToIncomingPayments, LinkExternalAccountToPaymentOrders, LinkIncomingPaymentToEvents, LinkIncomingPaymentToReturns, LinkInternalAccountToIncomingPayments, LinkPaymentOrderToEvents, LinkPaymentOrderToReturns
Class Attribute Summary collapse
-
.config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.config ⇒ Object (readonly)
Returns the value of attribute config.
16 17 18 |
# File 'lib/forest_admin_datasource_mambu_payments/plugins/relations/one_to_many_link_plugin.rb', line 16 def config @config end |
Class Method Details
.link(host:, to:, name:, origin_key:) ⇒ Object
19 20 21 |
# File 'lib/forest_admin_datasource_mambu_payments/plugins/relations/one_to_many_link_plugin.rb', line 19 def self.link(host:, to:, name:, origin_key:) @config = { host: host, to: to, name: name, origin_key: origin_key } end |
Instance Method Details
#run(datasource_customizer, _collection_customizer = nil, _options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/forest_admin_datasource_mambu_payments/plugins/relations/one_to_many_link_plugin.rb', line 23 def run(datasource_customizer, _collection_customizer = nil, = {}) Plugins::Helpers.require_datasource!(datasource_customizer, self.class) cfg = self.class.config datasource_customizer.customize_collection(cfg[:host]) do |c| c.add_one_to_many_relation(cfg[:name], cfg[:to], origin_key: cfg[:origin_key], origin_key_target: 'id') end end |