Class: Morpher::Transform

Inherits:
Object
  • Object
show all
Includes:
AbstractType, Adamantium
Defined in:
lib/morpher/transform.rb

Overview

Composable transform declaration and execution

Defined Under Namespace

Classes: Array, Block, Boolean, Error, Exception, Hash, Index, Maybe, Named, Primitive, Sequence, Success

Instance Method Summary collapse

Instance Method Details

#arrayTransform

Build array transform

Returns:



35
36
37
# File 'lib/morpher/transform.rb', line 35

def array
  Array.new(self)
end

#callEither<Error, Object>

Apply transformation to input

Parameters:

  • input (Object)

Returns:



21
# File 'lib/morpher/transform.rb', line 21

abstract_method :call

#maybeTransform

Build maybe transform

Returns:



42
43
44
# File 'lib/morpher/transform.rb', line 42

def maybe
  Maybe.new(self)
end

#seq(transform) ⇒ Transform

Build sequence

Parameters:

Returns:



28
29
30
# File 'lib/morpher/transform.rb', line 28

def seq(transform)
  Sequence.new([self, transform])
end

#slugString

Default slug

Returns:

  • (String)


12
13
14
# File 'lib/morpher/transform.rb', line 12

def slug
  self.class.to_s
end

#to_procProc

Build Proc to transform input

Returns:

  • (Proc)


49
50
51
# File 'lib/morpher/transform.rb', line 49

def to_proc
  public_method(:call).to_proc
end