Sha256: 05a8182f05d6b62cf054c7ebe3c9e9768949fee94df7f053bbfb7b6b50784bec

Contents?: true

Size: 666 Bytes

Versions: 2

Compression:

Stored size: 666 Bytes

Contents

# frozen_string_literal: true

module Acb
  module Custom
    extend ActiveSupport::Concern

    included do
      class_attribute :registry, instance_accessor: false, instance_predicate: false, default: Registry.new
    end

    module ClassMethods
      def add_master_column(key:, **options)
        registry.push(MasterColumn.new(key, **options))
      end

      def use(columns)
        klass = Class.new do
          include Acb::Base
        end

        columns.each do |column|
          master_column = registry.lookup(column[:key])
          klass.add_column(master_column.to_column(column[:name]))
        end

        klass
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acb-0.2.1 lib/acb/custom.rb
acb-0.2.0 lib/acb/custom.rb