Class: Betterdocs::ControllerCollector
- Inherits:
-
Object
- Object
- Betterdocs::ControllerCollector
- Defined in:
- lib/betterdocs/controller_collector.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#element ⇒ Object
writeonly
Sets the attribute element.
Instance Method Summary collapse
- #action(action_name) ⇒ Object
- #actions ⇒ Object
- #add_element(klass, type, &block) ⇒ Object
- #configure_current_element(action_name) ⇒ Object
-
#initialize ⇒ ControllerCollector
constructor
A new instance of ControllerCollector.
- #section ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ ControllerCollector
Returns a new instance of ControllerCollector.
3 4 5 6 7 |
# File 'lib/betterdocs/controller_collector.rb', line 3 def initialize @actions = {} @element = nil @controller = nil end |
Instance Attribute Details
#controller ⇒ Object
Returns the value of attribute controller.
9 10 11 |
# File 'lib/betterdocs/controller_collector.rb', line 9 def controller @controller end |
#element=(value) ⇒ Object (writeonly)
Sets the attribute element
11 12 13 |
# File 'lib/betterdocs/controller_collector.rb', line 11 def element=(value) @element = value end |
Instance Method Details
#action(action_name) ⇒ Object
17 18 19 20 |
# File 'lib/betterdocs/controller_collector.rb', line 17 def action(action_name) action_name = action_name.to_sym @actions[action_name] end |
#actions ⇒ Object
13 14 15 |
# File 'lib/betterdocs/controller_collector.rb', line 13 def actions @actions.values.reject(&:private) end |
#add_element(klass, type, &block) ⇒ Object
26 27 28 29 |
# File 'lib/betterdocs/controller_collector.rb', line 26 def add_element(klass, type, &block) element = build_element(klass, type, &block) element.add_to_collector(self) end |
#configure_current_element(action_name) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/betterdocs/controller_collector.rb', line 31 def configure_current_element(action_name) if @element @element.configure_for_action(action_name) @actions[action_name] = @element end @element = nil self end |
#section ⇒ Object
22 23 24 |
# File 'lib/betterdocs/controller_collector.rb', line 22 def section @controller.ask_and_send(:section) end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/betterdocs/controller_collector.rb', line 40 def to_s ([ @controller, '=' * 79, actions * ("-" * 79 + "\n"), '' ]) * "\n" end |