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

Class Method Details

.wrap(cause, index) ⇒ Error

Create error at specified index

Parameters:

  • cause (Error)
  • index (Integer)

Returns:



144
145
146
147
148
149
150
151
# File 'lib/morpher/transform.rb', line 144

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

Parameters:

  • input (Object)

Returns:



158
159
160
# File 'lib/morpher/transform.rb', line 158

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

#slugArray<String>

Rendering slug

Returns:



165
166
167
# File 'lib/morpher/transform.rb', line 165

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