summaryrefslogtreecommitdiff
path: root/rubocop/model_helpers.rb
blob: 309723dc34caa0cea339cabea33b3727631503c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
module RuboCop
  module ModelHelpers
    # Returns true if the given node originated from the models directory.
    def in_model?(node)
      path = node.location.expression.source_buffer.name
      models_path = File.join(Dir.pwd, 'app', 'models')

      path.start_with?(models_path)
    end
  end
end