Skip to content

Instantly share code, notes, and snippets.

@twopoint718
Created February 17, 2012 18:18
Show Gist options
  • Select an option

  • Save twopoint718/1854703 to your computer and use it in GitHub Desktop.

Select an option

Save twopoint718/1854703 to your computer and use it in GitHub Desktop.
george boole ate my brain
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
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