Class: ActiveRecord::Type::Registration
- Inherits:
-
Object
- Object
- ActiveRecord::Type::Registration
- Defined in:
- lib/active_record/type/adapter_specific_registry.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #call(_registry, *args, adapter: nil, **kwargs) ⇒ Object
-
#initialize(name, block, adapter: nil, override: nil) ⇒ Registration
constructor
A new instance of Registration.
- #matches?(type_name, *args, **kwargs) ⇒ Boolean
Constructor Details
#initialize(name, block, adapter: nil, override: nil) ⇒ Registration
Returns a new instance of Registration.
51 52 53 54 55 56 |
# File 'lib/active_record/type/adapter_specific_registry.rb', line 51 def initialize(name, block, adapter: nil, override: nil) @name = name @block = block @adapter = adapter @override = override end |
Instance Method Details
#<=>(other) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/active_record/type/adapter_specific_registry.rb', line 70 def <=>(other) if conflicts_with?(other) raise TypeConflictError.new("Type #{name} was registered for all adapters, but shadows a native type with the same name for #{other.adapter}".squish) end priority <=> other.priority end |
#call(_registry, *args, adapter: nil, **kwargs) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/active_record/type/adapter_specific_registry.rb', line 58 def call(_registry, *args, adapter: nil, **kwargs) if kwargs.any? # https://bugs.ruby-lang.org/issues/10856 block.call(*args, **kwargs) else block.call(*args) end end |
#matches?(type_name, *args, **kwargs) ⇒ Boolean
66 67 68 |
# File 'lib/active_record/type/adapter_specific_registry.rb', line 66 def matches?(type_name, *args, **kwargs) type_name == name && matches_adapter?(**kwargs) end |