Skip to content

Instantly share code, notes, and snippets.

@naps62
Last active February 26, 2016 10:23
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 naps62/7ee35e53635e1b7ee9ae to your computer and use it in GitHub Desktop.
Save naps62/7ee35e53635e1b7ee9ae to your computer and use it in GitHub Desktop.
egonSchiele/contracts.ruby - issue #229
require "contracts"
C = Contracts
module ModuleWithContracts
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
include Contracts::Core
Contract C::None => String
def foo
"bar"
end
end
end
# this class works
class ContractsThenModule
include Contracts::Core
include ModuleWithContracts
Contract C::Num => C::Num
def double(x)
x * 2
end
end
# but this one, with the module included before the contracts, fails to compile
class ModuleThenContracts
include ModuleWithContracts
include Contracts::Core
# fails on this line
Contract C::Num => C::Num
def double(x)
x * 2
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment