base_loader.rb 406 Bytes
Newer Older
Nick Thomas's avatar
Nick Thomas committed
1
# Helper methods for all loaders
2 3 4 5 6 7
module Loaders::BaseLoader
  extend ActiveSupport::Concern

  class_methods do
    # Convert a class method into a resolver proc. The method should follow the
    # (obj, args, ctx) calling convention
Nick Thomas's avatar
Nick Thomas committed
8 9 10 11 12 13 14 15
    def [](sym)
      resolver = method(sym)
      raise ArgumentError.new("#{self}.#{sym} is not a resolver") unless resolver.arity == 3

      resolver
    end
  end
end