Created
February 17, 2012 18:18
-
-
Save twopoint718/1854703 to your computer and use it in GitHub Desktop.
george boole ate my brain
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
| def prithee_shall_i_do_some_stuff? | |
| (hash[:foo] == "1" || !hash.has_key?(:foo)) && \ | |
| (!hash["bar"].include?("Horses") && \ | |
| hash["baz"].blank? && \ | |
| hash["quux"].blank? && \ | |
| hash["buzz"].blank?) | |
| end |
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 Hash | |
| def true_of?(subject_key, &block) | |
| TrueOf.new(self).instance_eval(&block) | |
| end | |
| end | |
| class TrueOf | |
| attr_reader :value, :key | |
| def initialize(hash, key, &block) | |
| @hash = hash | |
| @key = key | |
| @value = hash[key] | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment