Module: Bail::Helpers
- Included in:
- ConditionParser, ConditionTester
- Defined in:
- lib/bail/helpers.rb
Instance Method Summary collapse
Instance Method Details
#condition_hash_to_lambda(condition) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/bail/helpers.rb', line 10 def condition_hash_to_lambda(condition) test = questionable(condition.keys.first) against = condition.values.first ->(testee) { testee.send(test, against) } end |
#questionable(condition) ⇒ Object
4 5 6 7 8 |
# File 'lib/bail/helpers.rb', line 4 def questionable(condition) # TODO: Object.new.extend(Enumerable).respond_to? condition # WHY: to allow {is_a: Thing} which becomes - [...].is_a? Thing condition.to_s.gsub(/\?$/, '').gsub(/$/, '?').to_sym end |