Sha256: fd0a1291e184915046d287f057492b64c9cb6389b11570c97fb54ec25a2bc53c

Contents?: true

Size: 707 Bytes

Versions: 2

Compression:

Stored size: 707 Bytes

Contents

module Nyanko
  module Invoker
    class FunctionFinder
      def self.find(context, options)
        new(context, options).find
      end

      attr_reader :context, :options

      delegate :active_if_options, :as, :label, :unit_name, :to => :options

      def initialize(context, options)
        @context = context
        @options = options
      end

      def find
        active? && find_function
      end

      def scope
        as || context.class
      end

      def unit
        Loader.load(unit_name)
      end

      def find_function
        unit.find_function(scope, label)
      end

      def active?
        unit.try(:active?, context, active_if_options)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nyanko-0.0.9 lib/nyanko/invoker/function_finder.rb
nyanko-0.0.8 lib/nyanko/invoker/function_finder.rb