Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can implements be called on a module instead of a class? #13

Open
PikachuEXE opened this issue Jun 10, 2019 · 2 comments
Open

Can implements be called on a module instead of a class? #13

PikachuEXE opened this issue Jun 10, 2019 · 2 comments

Comments

@PikachuEXE
Copy link

PikachuEXE commented Jun 10, 2019

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 added a commit that referenced this issue Jun 10, 2019
- Add `Tips` section as per community suggestion, fixes #8

- Add documentation for multi-behavior, fixes #13
edisonywh added a commit that referenced this issue Jun 10, 2019
- Add `Tips` section as per community suggestion, fixes #8

- Add documentation for multi-behavior, fixes #13
edisonywh added a commit that referenced this issue Jun 10, 2019
- Add `Tips` section as per community suggestion, fixes #8

- Add documentation for multi-behavior, fixes #13
@edisonywh
Copy link
Owner

👋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 :)

@edisonywh edisonywh reopened this Jun 10, 2019
@PikachuEXE
Copy link
Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants