class RuboCop::Cop::DatabaseValidations::BelongsTo
Use `db_belongs`_to instead of `belongs_to`.
@example
# bad belongs_to :company # good db_belongs_to :company
Constants
- MSG
- NON_SUPPORTED_OPTIONS
Public Instance Methods
on_send(node)
click to toggle source
# File lib/database_validations/rubocop/cop/belongs_to.rb, line 26 def on_send(node) return unless belongs_to?(node) return unless supported?(node) add_offense(node, location: :selector) end
Private Instance Methods
supported?(node)
click to toggle source
# File lib/database_validations/rubocop/cop/belongs_to.rb, line 35 def supported?(node) options = node.arguments.last return true unless options.hash_type? options.each_child_node.none? do |option| NON_SUPPORTED_OPTIONS.include? option_name(option) end end