Module: Acb::Custom::ClassMethods

Defined in:
lib/acb/custom.rb

Instance Method Summary collapse

Instance Method Details

#add_master_column(key:, **options) ⇒ Object



12
13
14
# File 'lib/acb/custom.rb', line 12

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

#use(columns) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/acb/custom.rb', line 16

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