-
Notifications
You must be signed in to change notification settings - Fork 124
/
import.rb
34 lines (29 loc) · 935 Bytes
/
import.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require "rails_admin/config/sections/base"
module RailsAdmin
module Config
module Sections
# Configuration of the navigation view
class Import < RailsAdmin::Config::Sections::Base
register_instance_option(:mapping_key) do
:name
end
register_instance_option(:mapping_key_list) do
[]
end
register_instance_option(:default_excluded_fields) do
[:id, :_id, :created_at, :updated_at, :c_at, :u_at, :deleted_at]
end
end
end
end
end
section = RailsAdmin::Config::Sections::Import
name = :import
# Manually add to Rails Admin as a model configuration section until
# there is a better API to do this
RailsAdmin::Config::Model.send(:define_method, name) do |&block|
@sections = {} unless @sections
@sections[name] = section.new(self) unless @sections[name]
@sections[name].instance_eval(&block) if block
@sections[name]
end