Class: Morpher::Transform::Block

Inherits:
Morpher::Transform show all
Defined in:
lib/morpher/transform.rb

Overview

Transform based on a (captured) block with added name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Morpher::Transform

#array, #maybe, #seq

Class Method Details

.capture(name, &block) ⇒ Object



106
107
108
# File 'lib/morpher/transform.rb', line 106

def self.capture(name, &block)
  new(block: block, name: name)
end

Instance Method Details

#call(input) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/morpher/transform.rb', line 110

def call(input)
  block
    .call(input)
    .lmap do |message|
      Error.new(
        cause:     nil,
        input:     input,
        message:   message,
        transform: self
      )
    end
end

#slugObject



123
124
125
# File 'lib/morpher/transform.rb', line 123

def slug
  name
end