Sha256: 69b3e801d317afb5b531d7936f4a424687ea150254f8f6a6502ea598f7284aa1

Contents?: true

Size: 654 Bytes

Versions: 1

Compression:

Stored size: 654 Bytes

Contents

module Nyanko
  module UnitProxyProvider
    extend ActiveSupport::Concern

    included do
      extend UnitProxyProvider
      include Helper
    end

    def method_missing(method_name, *args, &block)
      if Array.wrap(Config.proxy_method_name).include?(method_name)
        UnitProxyProvider.class_eval do
          define_method(method_name) do |*_args|
            name = _args.first || Function.current_unit.try(:unit_name)
            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.7 lib/nyanko/unit_proxy_provider.rb