Class: Spoom::Deadcode::Plugins::ActiveModel
- Defined in:
- lib/spoom/deadcode/plugins/active_model.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#on_send(send) ⇒ Object
: (Send send) -> void.
Methods inherited from Base
ignore_classes_inheriting_from, ignore_classes_named, ignore_constants_named, ignore_methods_named, ignore_modules_named, #initialize, #internal_on_define_accessor, #internal_on_define_class, #internal_on_define_constant, #internal_on_define_method, #internal_on_define_module, #on_define_accessor, #on_define_class, #on_define_constant, #on_define_method, #on_define_module
Constructor Details
This class inherits a constructor from Spoom::Deadcode::Plugins::Base
Instance Method Details
#on_send(send) ⇒ Object
: (Send send) -> void
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/spoom/deadcode/plugins/active_model.rb', line 13 def on_send(send) return if send.recv case send.name when "attribute", "attributes" send.each_arg(Prism::SymbolNode) do |arg| @index.reference_method(arg.unescaped, send.location) end when "validate", "validates", "validates!", "validates_each" send.each_arg(Prism::SymbolNode) do |arg| @index.reference_method(arg.unescaped, send.location) end send.each_arg_assoc do |key, value| next unless key.is_a?(Prism::SymbolNode) key = key.unescaped case key when "if", "unless" @index.reference_method(value.unescaped, send.location) if value.is_a?(Prism::SymbolNode) else @index.reference_constant(camelize(key), send.location) if value.is_a?(Prism::HashNode) (value, send.location) end end end when "validates_with" arg = send.args.first if arg.is_a?(Prism::SymbolNode) @index.reference_constant(arg.unescaped, send.location) end end end |