Module: Reek::AST::SexpExtensions::SendNode
- Defined in:
- lib/reek/ast/sexp_extensions/send.rb
Overview
Utility methods for :send nodes.
Constant Summary collapse
- ATTR_DEFN_METHODS =
[:attr_writer, :attr_accessor].freeze
Instance Method Summary collapse
- #args ⇒ Object
-
#attr_with_writable_flag? ⇒ Boolean
Handles the case where we create an attribute writer via: attr :foo, true.
- #attribute_writer? ⇒ Boolean
- #const_receiver? ⇒ Boolean private
- #data_definition_call? ⇒ Boolean private
- #data_definition_receiver? ⇒ Boolean private
- #module_creation_call? ⇒ Boolean
- #module_creation_receiver? ⇒ Boolean private
- #name ⇒ Object
- #object_creation_call? ⇒ Boolean
- #participants ⇒ Object
- #receiver ⇒ Object
Instance Method Details
#args ⇒ Object
18 19 20 |
# File 'lib/reek/ast/sexp_extensions/send.rb', line 18 def args children[2..] end |
#attr_with_writable_flag? ⇒ Boolean
Handles the case where we create an attribute writer via: attr :foo, true
44 45 46 |
# File 'lib/reek/ast/sexp_extensions/send.rb', line 44 def attr_with_writable_flag? name == :attr && args.any? && args.last.type == :true end |
#attribute_writer? ⇒ Boolean
37 38 39 40 |
# File 'lib/reek/ast/sexp_extensions/send.rb', line 37 def attribute_writer? ATTR_DEFN_METHODS.include?(name) || attr_with_writable_flag? end |
#const_receiver? ⇒ Boolean (private)
62 63 64 |
# File 'lib/reek/ast/sexp_extensions/send.rb', line 62 def const_receiver? receiver && receiver.type == :const end |
#data_definition_call? ⇒ Boolean (private)
54 55 56 |
# File 'lib/reek/ast/sexp_extensions/send.rb', line 54 def data_definition_call? name == :define end |
#data_definition_receiver? ⇒ Boolean (private)
58 59 60 |
# File 'lib/reek/ast/sexp_extensions/send.rb', line 58 def data_definition_receiver? const_receiver? && receiver.simple_name == :Data end |
#module_creation_call? ⇒ Boolean
26 27 28 29 30 31 |
# File 'lib/reek/ast/sexp_extensions/send.rb', line 26 def module_creation_call? return true if object_creation_call? && module_creation_receiver? return true if data_definition_call? && data_definition_receiver? false end |
#module_creation_receiver? ⇒ Boolean (private)
50 51 52 |
# File 'lib/reek/ast/sexp_extensions/send.rb', line 50 def module_creation_receiver? const_receiver? && [:Class, :Struct].include?(receiver.simple_name) end |
#name ⇒ Object
14 15 16 |
# File 'lib/reek/ast/sexp_extensions/send.rb', line 14 def name children[1] end |
#object_creation_call? ⇒ Boolean
33 34 35 |
# File 'lib/reek/ast/sexp_extensions/send.rb', line 33 def object_creation_call? name == :new end |
#participants ⇒ Object
22 23 24 |
# File 'lib/reek/ast/sexp_extensions/send.rb', line 22 def participants ([receiver] + args).compact end |
#receiver ⇒ Object
10 11 12 |
# File 'lib/reek/ast/sexp_extensions/send.rb', line 10 def receiver children.first end |