Sha256: 788994bb14d7d4cfb03f1ee299acc78966ca181117fb02de1aaac3dded7e6361
Contents?: true
Size: 600 Bytes
Versions: 3
Compression:
Stored size: 600 Bytes
Contents
# frozen_string_literal: true module PlainModel class AssociationBuilder attr_reader :model_class, :options def initialize(model_class, options = {}) @model_class = model_class @options = options end def load_records(name, records, context: nil, includes: []) apply = options.fetch(:apply) { :"_records_for_#{name}" } args = [records, context: context, includes: includes, association: name] if apply.is_a?(Symbol) model_class.public_send(apply, *args) else model_class.instance_exec(*args, &apply) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
plain_model-0.2.1 | lib/plain_model/association_builder.rb |
plain_model-0.2.0 | lib/plain_model/association_builder.rb |
plain_model-0.1.0 | lib/plain_model/association_builder.rb |