debian-mirror-gitlab/app/models/concerns/sha_attribute.rb

22 lines
630 B
Ruby
Raw Normal View History

2017-09-10 17:25:29 +05:30
module ShaAttribute
extend ActiveSupport::Concern
module ClassMethods
def sha_attribute(name)
2018-03-17 18:26:18 +05:30
return if ENV['STATIC_VERIFICATION']
2017-09-10 17:25:29 +05:30
return unless table_exists?
column = columns.find { |c| c.name == name.to_s }
# In case the table doesn't exist we won't be able to find the column,
# thus we will only check the type if the column is present.
if column && column.type != :binary
raise ArgumentError,
"sha_attribute #{name.inspect} is invalid since the column type is not :binary"
end
attribute(name, Gitlab::Database::ShaAttribute.new)
end
end
end