Class: Betterdocs::Dsl::Controller::Controller

Inherits:
ControllerBase show all
Defined in:
lib/betterdocs/dsl/controller/controller.rb

Instance Method Summary collapse

Methods inherited from ControllerBase

inherited, #initialize

Methods included from Betterdocs::Dsl::Common

#set_context

Constructor Details

This class inherits a constructor from Betterdocs::Dsl::Controller::ControllerBase

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Betterdocs::Dsl::Common

Instance Method Details

#add_to_collector(collector) ⇒ Object



28
29
30
# File 'lib/betterdocs/dsl/controller/controller.rb', line 28

def add_to_collector(collector)
  collector.controller = self
end

#nameObject



4
5
6
# File 'lib/betterdocs/dsl/controller/controller.rb', line 4

def name
  @name ||= controller.to_s.underscore.sub(/_controller\z/, '').to_sym
end

#to_sObject



24
25
26
# File 'lib/betterdocs/dsl/controller/controller.rb', line 24

def to_s
  [ controller, '', "url: #{url}", '', description, '' ] * "\n"
end

#urlObject



12
13
14
15
16
17
18
# File 'lib/betterdocs/dsl/controller/controller.rb', line 12

def url
  Betterdocs::Global.url_for(
    controller: name,
    action: :index,
    format: 'json'
  )
end

#url_helpersObject



20
21
22
# File 'lib/betterdocs/dsl/controller/controller.rb', line 20

def url_helpers
  Betterdocs::Global.url_helpers
end