Class: ActiveRecord::Type::Registration

Inherits:
Object
  • Object
show all
Defined in:
activerecord/lib/active_record/type/adapter_specific_registry.rb

Overview

:nodoc:

Direct Known Subclasses

DecorationRegistration

Instance Method Summary collapse

Constructor Details

#initialize(name, block, adapter: nil, override: nil) ⇒ Registration

Returns a new instance of Registration.


48
49
50
51
52
53
# File 'activerecord/lib/active_record/type/adapter_specific_registry.rb', line 48

def initialize(name, block, adapter: nil, override: nil)
  @name = name
  @block = block
  @adapter = adapter
  @override = override
end

Instance Method Details

#<=>(other) ⇒ Object


63
64
65
66
67
68
69
70
# File 'activerecord/lib/active_record/type/adapter_specific_registry.rb', line 63

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


55
56
57
# File 'activerecord/lib/active_record/type/adapter_specific_registry.rb', line 55

def call(_registry, *args, adapter: nil, **kwargs)
  block.call(*args, **kwargs)
end

#matches?(type_name, *args, **kwargs) ⇒ Boolean

Returns:


59
60
61
# File 'activerecord/lib/active_record/type/adapter_specific_registry.rb', line 59

def matches?(type_name, *args, **kwargs)
  type_name == name && matches_adapter?(**kwargs)
end