Class: Morpher::Transform::Index

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

Overview

Index attached to a transform

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Morpher::Transform

#array, #maybe, #seq

Class Method Details

.wrap(cause, index) ⇒ Error

Create error at specified index



167
168
169
170
171
172
173
174
# File 'lib/morpher/transform.rb', line 167

def self.wrap(cause, index)
  Error.new(
    cause:     cause,
    input:     cause.input,
    message:   nil,
    transform: new(index: index, transform: cause.transform)
  )
end

Instance Method Details

#call(input) ⇒ Either<Error, Object>

Apply transformation to input



181
182
183
# File 'lib/morpher/transform.rb', line 181

def call(input)
  transform.call(input).lmap(&method(:wrap_error))
end

#slugArray<String>

Rendering slug



188
189
190
# File 'lib/morpher/transform.rb', line 188

def slug
  '%<index>d' % { index: index }
end