Class: Spektr::Targets::Controller::Action
- Inherits:
-
Exp::Definition
- Object
- Exp::Base
- Exp::Definition
- Spektr::Targets::Controller::Action
- Defined in:
- lib/spektr/targets/controller.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#template ⇒ Object
Returns the value of attribute template.
Attributes inherited from Exp::Definition
Attributes inherited from Exp::Base
#arguments, #ast, #body, #location, #name, #options, #type
Instance Method Summary collapse
-
#initialize(ast, controller) ⇒ Action
constructor
A new instance of Action.
Methods inherited from Exp::Definition
Methods inherited from Exp::Base
#handler_missing, #process, #send?
Constructor Details
#initialize(ast, controller) ⇒ Action
Returns a new instance of Action.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/spektr/targets/controller.rb', line 46 def initialize(ast, controller) super(ast) @template = nil split = [] if controller.parent split = controller.parent.split('::').map { |e| e.delete_suffix('Controller') }.map(&:downcase) if split.size > 1 split.pop @template = "#{split.join('/')}/#{@template}" end end split = split.concat(controller.name.delete_suffix('Controller').split('::').map(&:downcase)).uniq split.delete('application') @template = File.join(*split, name.to_s) @body.each do |exp| if exp.send? && (exp.name == :render && exp.arguments.any?) if exp.arguments.first.type == :sym @template = File.join(controller.name.delete_suffix('Controller').underscore, exp.arguments.first.name.to_s) elsif exp.arguments.first.type == :str @template = exp.arguments.first.name end end end end |
Instance Attribute Details
#controller ⇒ Object
Returns the value of attribute controller.
44 45 46 |
# File 'lib/spektr/targets/controller.rb', line 44 def controller @controller end |
#template ⇒ Object
Returns the value of attribute template.
44 45 46 |
# File 'lib/spektr/targets/controller.rb', line 44 def template @template end |