class ActiveModel::Type::Registry
:nodoc:
def initialize
def initialize @registrations = {} end
def initialize_copy(other)
def initialize_copy(other) @registrations = @registrations.dup super end
def lookup(symbol, ...)
def lookup(symbol, ...) registration = registrations[symbol] if registration registration.call(symbol, ...) else raise ArgumentError, "Unknown type #{symbol.inspect}" end end
def register(type_name, klass = nil, &block)
def register(type_name, klass = nil, &block) unless block_given? block = proc { |_, *args| klass.new(*args) } block.ruby2_keywords if block.respond_to?(:ruby2_keywords) end registrations[type_name] = block end