Created
January 14, 2013 21:43
-
-
Save jsuchal/4533802 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SRPViolationError < StandardError | |
| def initialize(klass) | |
| @klass = klass | |
| end | |
| def message | |
| "Class #{@klass} surely does something AND detects SRP violation, right? Well, your class should do only one thing! :D" | |
| end | |
| end | |
| module SRPViolationMixin | |
| def self.included(base) | |
| raise SRPViolationError.new(base) | |
| end | |
| end | |
| class Object | |
| def acts_as_srp_violation | |
| include SRPViolationMixin | |
| end | |
| end | |
| class MyCleanClass | |
| acts_as_srp_violation | |
| def go | |
| puts 'Go!' | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment