Module: Behaves
- Defined in:
- lib/behaves.rb,
lib/behaves/version.rb
Constant Summary collapse
- VERSION =
"0.3.0"
Instance Method Summary collapse
- #behaves_like(klass) ⇒ Object
- #implements(*methods, **opts) ⇒ Object
- #inject_behaviors(&block) ⇒ Object
Instance Method Details
#behaves_like(klass) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/behaves.rb', line 20 def behaves_like(klass) add_injected_behaviors(klass) at_exit { check_for_unimplemented(klass, :public) check_for_unimplemented(klass, :private) } end |
#implements(*methods, **opts) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/behaves.rb', line 5 def implements(*methods, **opts) @_public_behaviors ||= Set.new @_private_behaviors ||= Set.new if opts[:private] == true @_private_behaviors += Set.new(methods) else @_public_behaviors += Set.new(methods) end end |
#inject_behaviors(&block) ⇒ Object
16 17 18 |
# File 'lib/behaves.rb', line 16 def inject_behaviors (&block) @inject_behaviors ||= block end |