Sha256: e6d70a722e270c88488c2b46eb4d49184fb88d5e2eabc683b8090ef25441cde2

Contents?: true

Size: 621 Bytes

Versions: 1

Compression:

Stored size: 621 Bytes

Contents

module Nyanko
  module UnitProxyProvider
    extend ActiveSupport::Concern

    included do
      extend UnitProxyProvider
      include Helper
    end

    def method_missing(method_name, *args, &block)
      if method_name == Config.proxy_method_name.to_sym
        class_eval do
          define_method(method_name) do |*_args|
            name = _args.first || Function.current_unit.try(:to_key)
            if name && unit = Loader.load(name)
              UnitProxy.new(unit, self)
            end
          end
        end
        send(method_name, args.first)
      else
        super
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nyanko-0.0.6 lib/nyanko/unit_proxy_provider.rb