BigW Consortium Gitlab

migration_helpers.rb 363 Bytes
Newer Older
1 2 3 4 5
module RuboCop
  # Module containing helper methods for writing migration cops.
  module MigrationHelpers
    # Returns true if the given node originated from the db/migrate directory.
    def in_migration?(node)
6 7 8
      dirname = File.dirname(node.location.expression.source_buffer.name)

      dirname.end_with?('db/migrate', 'db/post_migrate')
9 10 11
    end
  end
end