Can `implements` be called on a module instead of a class?
PikachuEXE opened this issue · 2 comments
PikachuEXE commented
The example class Animal
seems useless (for creating objects)
Also would be good to have example for "multi-inheritance"
module Hunter
extend Behaves
implements(:hunt)
end
module Prey
extend Behaves
implements(:run, :hide)
end
class Shark
extend Behaves
behaves_like Hunter
behaves_like Prey
# Something something
end
edisonywh commented
👋Hey thanks for opening this issue! Yeah I think it already supports Module
though, can you verify that?
And thanks for the great idea! I've just added that into the README :)
PikachuEXE commented
I think it can be used
But I can only see error on exit
, not on load (which is why #12 might be useful)
Also another (not very big) issue: calling behaves_like
would cause duplicate errors
Traceback (most recent call last):
1: from /Users/pikachuexe/projects/ruby/gems/behaves/lib/behaves.rb:17:in `block in behaves_like'
/Users/pikachuexe/projects/ruby/gems/behaves/lib/behaves.rb:32:in `detect_unimplemented_methods': Expected `Shark` to behave like `Prey`, but `run, hide` are not implemented. (NotImplementedError)
Traceback (most recent call last):
1: from /Users/pikachuexe/projects/ruby/gems/behaves/lib/behaves.rb:17:in `block in behaves_like'
/Users/pikachuexe/projects/ruby/gems/behaves/lib/behaves.rb:32:in `detect_unimplemented_methods': Expected `Shark` to behave like `Prey`, but `run, hide` are not implemented. (NotImplementedError)
1: from /Users/pikachuexe/projects/ruby/gems/behaves/lib/behaves.rb:17:in `block in behaves_like'
/Users/pikachuexe/projects/ruby/gems/behaves/lib/behaves.rb:32:in `detect_unimplemented_methods': Expected `Shark` to behave like `Hunter`, but `hunt` are not implemented. (NotImplementedError)