Class: Spektr::Targets::Controller::Action
- Inherits:
-
Object
- Object
- Spektr::Targets::Controller::Action
- Defined in:
- lib/spektr/targets/controller.rb
Instance Attribute Summary collapse
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#name ⇒ Object
Returns the value of attribute name.
-
#node ⇒ Object
Returns the value of attribute node.
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(node, controller) ⇒ Action
constructor
A new instance of Action.
Constructor Details
#initialize(node, controller) ⇒ Action
Returns a new instance of Action.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/spektr/targets/controller.rb', line 47 def initialize(node, controller) @node = node @name = node.name @template = nil @controller = controller split = [] if controller.parent && controller.parent != 'ApplicationController' 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.split('::').map do |n| n.delete_suffix('Controller') end.map(&:downcase)).uniq split.delete('application') @template = File.join(*split, name.to_s) # TODO: set template from render # @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.
45 46 47 |
# File 'lib/spektr/targets/controller.rb', line 45 def controller @controller end |
#name ⇒ Object
Returns the value of attribute name.
45 46 47 |
# File 'lib/spektr/targets/controller.rb', line 45 def name @name end |
#node ⇒ Object
Returns the value of attribute node.
45 46 47 |
# File 'lib/spektr/targets/controller.rb', line 45 def node @node end |
#template ⇒ Object
Returns the value of attribute template.
45 46 47 |
# File 'lib/spektr/targets/controller.rb', line 45 def template @template end |
Instance Method Details
#body ⇒ Object
79 80 81 |
# File 'lib/spektr/targets/controller.rb', line 79 def body @node.body.respond_to?(:body) ? @node.body.body : @node.body end |