Sha256: 8790a3e422b0644a486ba8da62cbb1cda1da1abe3edc92835afe1c22fc0bd2af
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
# frozen_string_literal: true module Clowne module Adapters # :nodoc: all class Sequel module Resolvers class Association class << self # rubocop: disable Metrics/ParameterLists def call(source, record, declaration, adapter:, params:, **_options) with_clonable(source, record, declaration) do reflection = source.class.association_reflections[declaration.name.to_sym] cloner_class = Associations.cloner_for(reflection) cloner_class.new(reflection, source, declaration, adapter, params).call(record) record end end # rubocop: enable Metrics/ParameterLists private def with_clonable(source, record, declaration) if clonable_assoc?(source, declaration) yield(record) else warn <<-WARN Relation #{declaration.name} of #{source.class.name} does not configure for Sequel::Plugins::NestedAttributes WARN end record end def clonable_assoc?(source, declaration) source.class.plugins.include?(::Sequel::Plugins::NestedAttributes) && source.respond_to?(:"#{declaration.name}_attributes=") end end end end end end end Clowne::Adapters::Sequel.register_resolver( :association, Clowne::Adapters::Sequel::Resolvers::Association )
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
clowne-1.3.0 | lib/clowne/adapters/sequel/resolvers/association.rb |
clowne-1.2.0 | lib/clowne/adapters/sequel/resolvers/association.rb |