Skip to content

Instantly share code, notes, and snippets.

@indigoviolet
Created December 23, 2017 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indigoviolet/034e4ec3967383395c88501c00f10b73 to your computer and use it in GitHub Desktop.
Save indigoviolet/034e4ec3967383395c88501c00f10b73 to your computer and use it in GitHub Desktop.
fin blog embed
class ActiveRecordRelation < Contracts::CallableClass
def initialize(klass)
@klass_contract = Contracts::Eq[klass]
end
def valid?(relation)
Contract.valid?(relation, ActiveRecord::Relation) && Contract.valid?(relation.klass, @klass_contract)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment