Class: Trains::Visitor::Controller
- Includes:
- Utils::Args
- Defined in:
- lib/trains/visitor/controller.rb
Overview
Visitor that parses controllers and returns a DTO::Controller object
Constant Summary collapse
- TRACKED_CALLBACKS =
[ :http_basic_authenticate_with ].freeze
Instance Method Summary collapse
-
#initialize ⇒ Controller
constructor
A new instance of Controller.
- #on_class(node) ⇒ Object
- #result ⇒ Object
Methods included from Utils::Args
#parse_args, #parse_hash, #parse_value
Constructor Details
#initialize ⇒ Controller
Returns a new instance of Controller.
17 18 19 20 21 22 |
# File 'lib/trains/visitor/controller.rb', line 17 def initialize @method_list = [] @methods = {} @class_name = nil @callbacks = [] end |
Instance Method Details
#on_class(node) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/trains/visitor/controller.rb', line 24 def on_class(node) class_name = node.identifier.const_name.to_s parent_class = node.parent_class.const_name.to_s return unless controller?(parent_class) @class_name = class_name find_callbacks(node) parse_body(node) unless node.body.nil? end |
#result ⇒ Object
34 35 36 |
# File 'lib/trains/visitor/controller.rb', line 34 def result DTO::Controller.new(name: @class_name, method_list: @method_list, callbacks: @callbacks) end |