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, #to_proc

Class Method Details

.capture(name, &block) ⇒ Object



113
114
115
# File 'lib/morpher/transform.rb', line 113

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

Instance Method Details

#call(input) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/morpher/transform.rb', line 117

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

#slugObject



130
131
132
# File 'lib/morpher/transform.rb', line 130

def slug
  name
end