Class: Inferno::Web::Controllers::Controller
- Inherits:
-
Hanami::Action
- Object
- Hanami::Action
- Inferno::Web::Controllers::Controller
show all
- Defined in:
- lib/inferno/apps/web/controllers/controller.rb
Direct Known Subclasses
Requests::Show, TestRuns::Create, TestRuns::Destroy, TestRuns::Results::Index, TestRuns::Show, TestSessions::ClientShow, TestSessions::Create, TestSessions::LastTestRun, TestSessions::Results::Index, TestSessions::SessionData::ApplyPreset, TestSessions::SessionData::Index, TestSessions::Show, TestSuites::CheckConfiguration, TestSuites::Index, TestSuites::Show
Class Method Summary
collapse
Class Method Details
.call ⇒ Object
7
8
9
|
# File 'lib/inferno/apps/web/controllers/controller.rb', line 7
def self.call(...)
new.call(...)
end
|
.inherited(subclass) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/inferno/apps/web/controllers/controller.rb', line 11
def self.inherited(subclass)
super
subclass.include Import[repo: "inferno.repositories.#{subclass.resource_name}"]
subclass.define_method(:serialize) do |*args|
Inferno::Web::Serializers.const_get(self.class.resource_class).render(*args)
end
subclass.after { |_req, res| res.format = :json if res.format == :all && res.body&.first&.first == '{' }
end
|
.resource_class ⇒ Object
30
31
32
|
# File 'lib/inferno/apps/web/controllers/controller.rb', line 30
def self.resource_class
name.split('::')[-2].singularize
end
|
.resource_name ⇒ Object
26
27
28
|
# File 'lib/inferno/apps/web/controllers/controller.rb', line 26
def self.resource_name
name.split('::')[-2].underscore
end
|