Sha256: 0b43ef7e9b364ffbaf3a7de362218cb9c26d23064620cd1d350b421a80dcd913

Contents?: true

Size: 1.08 KB

Versions: 5

Compression:

Stored size: 1.08 KB

Contents

module Mutant
  class Expression

    # Abstrat base class for methods expression
    class Methods < self

      MATCHERS = IceNine.deep_freeze(
        '.' => Matcher::Methods::Singleton,
        '#' => Matcher::Methods::Instance
      )

      register(
        /\A(?<scope_name>#{SCOPE_PATTERN})(?<scope_symbol>[.#])\z/
      )

      # Return method matcher
      #
      # @param [Env] env
      #
      # @return [Matcher::Method]
      #
      # @api private
      #
      def matcher(env)
        MATCHERS.fetch(scope_symbol).new(env, scope)
      end

    private

      # Return scope name
      #
      # @return [String]
      #
      # @api private
      #
      def scope_name
        match[__method__]
      end

      # Return scope
      #
      # @return [Class, Method]
      #
      # @api private
      #
      def scope
        Mutant.constant_lookup(scope_name)
      end

      # Return scope symbol
      #
      # @return [Symbol]
      #
      # @api private
      #
      def scope_symbol
        match[__method__]
      end

    end # Method
  end # Expression
end # Mutant

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mutant-0.6.3 lib/mutant/expression/methods.rb
mutant-0.6.2 lib/mutant/expression/methods.rb
mutant-0.6.0 lib/mutant/expression/methods.rb
mutant-0.5.26 lib/mutant/expression/methods.rb
mutant-0.5.25 lib/mutant/expression/methods.rb