Class: DuckRecord::Type::Registration
- Inherits:
-
Object
- Object
- DuckRecord::Type::Registration
- Defined in:
- lib/duck_record/type/registry.rb
Direct Known Subclasses
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #call(_registry, *args, **kwargs) ⇒ Object
-
#initialize(name, block, override: nil) ⇒ Registration
constructor
A new instance of Registration.
- #matches?(type_name, *args, **kwargs) ⇒ Boolean
Constructor Details
#initialize(name, block, override: nil) ⇒ Registration
Returns a new instance of Registration.
25 26 27 28 29 |
# File 'lib/duck_record/type/registry.rb', line 25 def initialize(name, block, override: nil) @name = name @block = block @override = override end |
Instance Method Details
#<=>(other) ⇒ Object
43 44 45 |
# File 'lib/duck_record/type/registry.rb', line 43 def <=>(other) priority <=> other.priority end |
#call(_registry, *args, **kwargs) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/duck_record/type/registry.rb', line 31 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
39 40 41 |
# File 'lib/duck_record/type/registry.rb', line 39 def matches?(type_name, *args, **kwargs) type_name == name end |