Class: ActiveEntity::Type::Registration

Inherits:
Object
  • Object
show all
Defined in:
lib/active_entity/type/registry.rb

Overview

:nodoc:

Direct Known Subclasses

DecorationRegistration

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Registration.



49
50
51
52
53
# File 'lib/active_entity/type/registry.rb', line 49

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

Instance Method Details

#<=>(other) ⇒ Object



67
68
69
# File 'lib/active_entity/type/registry.rb', line 67

def <=>(other)
  priority <=> other.priority
end

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



55
56
57
58
59
60
61
# File 'lib/active_entity/type/registry.rb', line 55

def call(_registry, *args, **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

Returns:



63
64
65
# File 'lib/active_entity/type/registry.rb', line 63

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