Class: ActiveRecord::Type::AdapterSpecificRegistry
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | activerecord/lib/active_record/type/adapter_specific_registry.rb |
Class Method Summary
- .new ⇒ AdapterSpecificRegistry constructor
Instance Attribute Summary
- #registrations readonly private
Instance Method Summary
Constructor Details
.new ⇒ AdapterSpecificRegistry
# File 'activerecord/lib/active_record/type/adapter_specific_registry.rb', line 7
def initialize @registrations = [] end
Instance Attribute Details
#registrations (readonly, private)
[ GitHub ]# File 'activerecord/lib/active_record/type/adapter_specific_registry.rb', line 38
attr_reader :registrations
Instance Method Details
#add_modifier(options, klass, **args)
[ GitHub ]# File 'activerecord/lib/active_record/type/adapter_specific_registry.rb', line 15
def add_modifier(, klass, **args) registrations << DecorationRegistration.new(, klass, **args) end
#find_registration(symbol, *args, **kwargs) (private)
[ GitHub ]# File 'activerecord/lib/active_record/type/adapter_specific_registry.rb', line 40
def find_registration(symbol, *args, **kwargs) registrations .select { |registration| registration.matches?(symbol, *args, **kwargs) } .max end
#initialize_copy(other)
[ GitHub ]# File 'activerecord/lib/active_record/type/adapter_specific_registry.rb', line 11
def initialize_copy(other) @registrations = @registrations.dup end
#lookup(symbol, *args, **kwargs)
[ GitHub ]# File 'activerecord/lib/active_record/type/adapter_specific_registry.rb', line 27
def lookup(symbol, *args, **kwargs) registration = find_registration(symbol, *args, **kwargs) if registration registration.call(self, symbol, *args, **kwargs) else raise ArgumentError, "Unknown type #{symbol.inspect}" end end
#register(type_name, klass = nil, **options, &block)
[ GitHub ]# File 'activerecord/lib/active_record/type/adapter_specific_registry.rb', line 19
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 << Registration.new(type_name, block, ** ) end