Module: Transit::Admin

Defined in:
lib/transit/admin.rb

Overview

Manages configuration options for models. When a model is managed via the admin, register it by Transit::Admin.register and passing a configuration block.

Examples:

Assign the columns to be displayed on “index”

Transit::Admin.register :model_name do |config|
  config.columns = [:name, :title]
end

Defined Under Namespace

Classes: DSL

Class Method Summary collapse

Class Method Details

.register(klass, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/transit/admin.rb', line 14

def self.register(klass, &block)
  klass = klass.to_s.classify.constantize
  unless klass.respond_to?(:admin_options)
    klass.send(:class_attribute, :admin_options, instance_writer: false)
  end
  dsl = klass.admin_options ||= DSL.new
  block.call(dsl)
  klass.admin_options = dsl
end