Class: Morpher::Transform
- Inherits:
-
Object
- Object
- Morpher::Transform
- Includes:
- AbstractType, Adamantium
- Defined in:
- lib/morpher/transform.rb
Overview
Composable transform declaration and execution
Direct Known Subclasses
Array, Block, Boolean, Exception, Hash, Hash::Key, Hash::Symbolize, Index, Maybe, Named, Primitive, Sequence, Success
Defined Under Namespace
Classes: Array, Block, Boolean, Error, Exception, Hash, Index, Maybe, Named, Primitive, Sequence, Success
Instance Method Summary collapse
-
#array ⇒ Transform
Build array transform.
-
#call ⇒ Either<Error, Object>
Apply transformation to input.
-
#maybe ⇒ Transform
Build maybe transform.
-
#seq(transform) ⇒ Transform
Build sequence.
-
#slug ⇒ String
Default slug.
-
#to_proc ⇒ Proc
Build Proc to transform input.
Instance Method Details
#array ⇒ Transform
Build array transform
35 36 37 |
# File 'lib/morpher/transform.rb', line 35 def array Array.new(self) end |
#call ⇒ Either<Error, Object>
Apply transformation to input
21 |
# File 'lib/morpher/transform.rb', line 21 abstract_method :call |
#maybe ⇒ Transform
Build maybe transform
42 43 44 |
# File 'lib/morpher/transform.rb', line 42 def maybe Maybe.new(self) end |
#seq(transform) ⇒ Transform
Build sequence
28 29 30 |
# File 'lib/morpher/transform.rb', line 28 def seq(transform) Sequence.new([self, transform]) end |
#slug ⇒ String
Default slug
12 13 14 |
# File 'lib/morpher/transform.rb', line 12 def slug self.class.to_s end |
#to_proc ⇒ Proc
Build Proc to transform input
49 50 51 |
# File 'lib/morpher/transform.rb', line 49 def to_proc public_method(:call).to_proc end |