Class: Admin::ShipsController::Controls

Inherits:
Object
  • Object
show all
Defined in:
lib/super/test_support/copy_app_templates/controllers/ships_controller.rb

Instance Method Summary collapse

Instance Method Details

#display_schema(action:) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/super/test_support/copy_app_templates/controllers/ships_controller.rb', line 26

def display_schema(action:)
  Super::Schema.new(Super::Display::SchemaTypes.new) do |fields, type|
    fields[:name] = type.dynamic(&:itself)
    fields[:registry] = type.dynamic(&:itself)
    fields[:class_name] = type.dynamic(&:itself)
    if action.show?
      fields[:created_at] = type.dynamic(&:iso8601)
      fields[:updated_at] = type.dynamic(&:iso8601)
    end
  end
end

#form_schema(action:) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/super/test_support/copy_app_templates/controllers/ships_controller.rb', line 38

def form_schema(action:)
  Super::Schema.new(Super::Form::SchemaTypes.new) do |fields, type|
    fields[:name] = type.generic("form_field_text")
    fields[:registry] = type.generic("form_field_text")
    fields[:class_name] = type.generic("form_field_text")
  end
end

#modelObject



14
15
16
# File 'lib/super/test_support/copy_app_templates/controllers/ships_controller.rb', line 14

def model
  Ship
end

#permitted_params(params, action:) ⇒ Object



22
23
24
# File 'lib/super/test_support/copy_app_templates/controllers/ships_controller.rb', line 22

def permitted_params(params, action:)
  params.require(:ship).permit(:name, :registry, :class_name)
end

#scope(action:) ⇒ Object



18
19
20
# File 'lib/super/test_support/copy_app_templates/controllers/ships_controller.rb', line 18

def scope(action:)
  Ship.all
end

#titleObject



10
11
12
# File 'lib/super/test_support/copy_app_templates/controllers/ships_controller.rb', line 10

def title
  Ship.name.pluralize
end