Class: ActiveRecord::Type::DecorationRegistration

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

Instance Method Summary collapse

Methods inherited from Registration

#<=>

Constructor Details

#initialize(options, klass, adapter: nil) ⇒ DecorationRegistration

Returns a new instance of DecorationRegistration.


96
97
98
99
100
# File 'lib/active_record/type/adapter_specific_registry.rb', line 96

def initialize(options, klass, adapter: nil)
  @options = options
  @klass = klass
  @adapter = adapter
end

Instance Method Details

#call(registry, *args, **kwargs) ⇒ Object


102
103
104
105
# File 'lib/active_record/type/adapter_specific_registry.rb', line 102

def call(registry, *args, **kwargs)
  subtype = registry.lookup(*args, **kwargs.except(*options.keys))
  klass.new(subtype)
end

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

Returns:


107
108
109
# File 'lib/active_record/type/adapter_specific_registry.rb', line 107

def matches?(*args, **kwargs)
  matches_adapter?(**kwargs) && matches_options?(**kwargs)
end

#priorityObject


111
112
113
# File 'lib/active_record/type/adapter_specific_registry.rb', line 111

def priority
  super | 4
end