Module: Defp::DefpMethods
- Defined in:
- lib/defp.rb
Instance Method Summary collapse
Instance Method Details
#_ ⇒ Object
32 33 34 |
# File 'lib/defp.rb', line 32 def _ false end |
#defp(*args) ⇒ Object
12 13 14 |
# File 'lib/defp.rb', line 12 def defp(*args) matches_pattern?(*args) ? Defp::Between.new : Defp::NullBetween.new end |
#matches_pattern?(*args) ⇒ Boolean
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/defp.rb', line 16 def matches_pattern?(*args) # arg[1] == called_by_method_args # arg[0] == pattern_args args.zip(@__last_args) .select { |arg| arg[0] } .all? do |arg| # TODO cleanup if arg[0].is_a? Hash pattern_args = arg[0].reject {|_,v| !v} pattern_args.keys.all? { |key| arg[1][key] == arg[0][key] } else arg[0] == arg[1] end end end |