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

Class Method Details

.capture(name, &block) ⇒ Object



83
84
85
# File 'lib/morpher/transform.rb', line 83

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

Instance Method Details

#call(input) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/morpher/transform.rb', line 87

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

#slugObject



100
101
102
# File 'lib/morpher/transform.rb', line 100

def slug
  name
end