Class: Drymm::Shapes::Node Abstract
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Drymm::Shapes::Node
- Extended by:
- Dry::Tuple::StructClassInterface
- Includes:
- Dry::Core::Constants, ASTMethods, JSONMethods
- Defined in:
- lib/drymm/shapes/node.rb
Overview
This class is abstract.
Dry::Struct abstract subclass, extended with Dry::Tuple::StructClassInterface
Direct Known Subclasses
Class Method Summary collapse
-
.type_enum(*input) ⇒ Dry::Types[Enum<Symbol>]
Shorthand to declare type as a enum.
-
.type_identifier(input = self) ⇒ Dry::Types::Type
Coercible symbol type with specific value — node type identifier (declared, for example, as ‘type` in Drymm::Shape::LogicNode.inherited).
Methods included from ASTMethods
Methods included from JSONMethods
Class Method Details
.type_enum(*input) ⇒ Dry::Types[Enum<Symbol>]
Shorthand to declare type as a enum
53 54 55 |
# File 'lib/drymm/shapes/node.rb', line 53 def type_enum(*input) type_identifier(input) end |
.type_identifier(klass) ⇒ Dry::Types::Type .type_identifier(name) ⇒ Dry::Types::Type .type_identifier(list) ⇒ Dry::Types::Type
Note:
To hook the assigned type identifier for specific subclass, just override this method.
Returns coercible symbol type with specific value — node type identifier (declared, for example, as ‘type` in Drymm::Shape::LogicNode.inherited).
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/drymm/shapes/node.rb', line 37 def type_identifier(input = self) case input when ::String, ::Symbol Drymm["types.sym"].constrained(eql: input.to_sym) when ::Array Drymm["types.sym"].enum(*input) when ::Module type_identifier(Drymm["fn.type_identifier"][input.name]) else raise ArgumentError end end |