Module: RuboCop::Cop::Obsession::Helpers

Included in:
Graphql::MutationName, MethodOrder, Rails::CallbackOneMethod, Rails::PrivateCallback, Rails::ServiceName
Defined in:
lib/rubocop/cop/obsession/mixin/helpers.rb

Instance Method Summary collapse

Instance Method Details

#rails_callback?(callback) ⇒ Boolean

Returns:

  • (Boolean)


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

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)


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

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

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