Class: AdminAssistant::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/admin_assistant/builder.rb

Defined Under Namespace

Classes: ColumnConfigLookup

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(admin_assistant) ⇒ Builder

Returns a new instance of Builder.



5
6
7
# File 'lib/admin_assistant/builder.rb', line 5

def initialize(admin_assistant)
  @admin_assistant = admin_assistant
end

Instance Attribute Details

#admin_assistantObject (readonly)

Returns the value of attribute admin_assistant.



3
4
5
# File 'lib/admin_assistant/builder.rb', line 3

def admin_assistant
  @admin_assistant
end

Instance Method Details

#[](column_name) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/admin_assistant/builder.rb', line 9

def [](column_name)
  ColumnConfigLookup.new(
    column_name,
    [@admin_assistant.base_settings, form, index, show, index.search], 
    @admin_assistant
  )
end

#actions(*a) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/admin_assistant/builder.rb', line 17

def actions(*a)
  if a.empty?
    @admin_assistant.actions
  else
    @admin_assistant.actions = a
  end
end

#destroy(&block) ⇒ Object



25
26
27
# File 'lib/admin_assistant/builder.rb', line 25

def destroy(&block)
  @admin_assistant.custom_destroy = block
end

#formObject



29
30
31
32
# File 'lib/admin_assistant/builder.rb', line 29

def form
  f = @admin_assistant.form_settings
  block_given? ? yield(f) : f
end

#indexObject



34
35
36
37
# File 'lib/admin_assistant/builder.rb', line 34

def index
  i = @admin_assistant.index_settings
  block_given? ? yield(i) : i
end

#model_class_name=(mcn) ⇒ Object



39
40
41
# File 'lib/admin_assistant/builder.rb', line 39

def model_class_name=(mcn)
  @admin_assistant.model_class_name = mcn
end

#showObject



43
44
45
46
# File 'lib/admin_assistant/builder.rb', line 43

def show
  s = @admin_assistant.show_settings
  block_given? ? yield(s) : s
end