Module: RuboCop::Cop::Helpers

Instance Method Summary collapse

Instance Method Details

#rails_callback?(callback) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rubocop/cop/mixin/helpers.rb', line 6

def rails_callback?(callback)
  return true if callback == 'validate'

  callback.match?(
    /
  ^(before|after|around)
  _.*
  (action|validation|create|update|save|destroy|commit|rollback)$
  /x
  )
end

#verb?(string) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/rubocop/cop/mixin/helpers.rb', line 18

def verb?(string)
  short_string = string[2..] if string.start_with?('re')

  verbs.include?(string) || verbs.include?(short_string)
end