Sha256: cf2197d7c63a35bf89141d01c3213f01034fbea6b33b662aceeed42287261b47

Contents?: true

Size: 896 Bytes

Versions: 11

Compression:

Stored size: 896 Bytes

Contents

module Aspector
  class MethodMatcher
    def initialize *match_data
      @match_data = match_data
      @match_data.flatten!
    end

    def match? method, aspect = nil
      @match_data.detect do |item|
        case item
        when String
          item == method
        when Regexp
          item =~ method
        when Symbol
          item.to_s == method
        when DeferredLogic
          value = aspect.aop_deferred_logic_results(item)
          if value
            new_matcher = MethodMatcher.new(value)
            new_matcher.match?(method)
          end
        when DeferredOption
          value = aspect.send(:aop_options)[item.key]
          if value
            new_matcher = MethodMatcher.new(value)
            new_matcher.match?(method)
          end
        end
      end
    end

    def to_s
      @match_data.map {|item| item.inspect }.join ", "
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
aspector-0.12.3 lib/aspector/method_matcher.rb
aspector-0.12.2 lib/aspector/method_matcher.rb
aspector-0.12.1 lib/aspector/method_matcher.rb
aspector-0.12.0 lib/aspector/method_matcher.rb
aspector-0.11.1 lib/aspector/method_matcher.rb
aspector-0.11.0 lib/aspector/method_matcher.rb
aspector-0.10.1 lib/aspector/method_matcher.rb
aspector-0.10.0 lib/aspector/method_matcher.rb
aspector-0.9.1 lib/aspector/method_matcher.rb
aspector-0.9.0 lib/aspector/method_matcher.rb
aspector-0.8.0 lib/aspector/method_matcher.rb