Class: Spektr::Targets::Routes::Action

Inherits:
Exp::Definition show all
Defined in:
lib/spektr/targets/routes.rb

Instance Attribute Summary collapse

Attributes inherited from Exp::Definition

#private, #protected

Attributes inherited from Exp::Base

#arguments, #ast, #body, #location, #name, #options, #type

Instance Method Summary collapse

Methods inherited from Exp::Definition

#process

Methods inherited from Exp::Base

#handler_missing, #process, #send?

Constructor Details

#initialize(ast, controller) ⇒ Action

Returns a new instance of Action.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/spektr/targets/routes.rb', line 18

def initialize(ast, controller)
  super(ast)
  @template = File.join(controller.name.delete_suffix("Controller").underscore, name.to_s)
  @body.each do |exp|
    if exp.send?
      if exp.name == :render
        if exp.arguments.first.type == :sym
          @template = File.join(controller.name.delete_suffix("Controller").underscore, exp.arguments.first.name.to_s)
        elsif
          if exp.arguments.first.type == :str
            @template = exp.arguments.first.name
          end
        end
      end
    end
  end
end

Instance Attribute Details

#controllerObject

Returns the value of attribute controller.



17
18
19
# File 'lib/spektr/targets/routes.rb', line 17

def controller
  @controller
end

#templateObject

Returns the value of attribute template.



17
18
19
# File 'lib/spektr/targets/routes.rb', line 17

def template
  @template
end