Class: SpecForge::Attribute::Transform

Inherits:
Parameterized show all
Defined in:
lib/spec_forge/attribute/transform.rb

Overview

Represents an attribute that transforms other attributes

This class provides transformation functions that can be applied to other attributes or values. It allows complex data manipulation without writing Ruby code.

Note: String concatenation is handled via string interpolation (}) syntax rather than transformation functions.

Constant Summary collapse

KEYWORD_REGEX =

Regular expression pattern that matches attribute keywords with this prefix Used for identifying this attribute type during parsing

Returns:

  • (Regexp)
/^transform\./i
TRANSFORM_METHODS =

The available transformation methods

Returns:

%w[].freeze

Instance Attribute Summary collapse

Attributes inherited from Parameterized

#arguments

Instance Method Summary collapse

Methods inherited from Parameterized

from_hash

Constructor Details

#initializeTransform

Creates a new transform attribute with the specified function and arguments

Raises:

See Also:



41
42
43
44
45
46
47
48
49
50
# File 'lib/spec_forge/attribute/transform.rb', line 41

def initialize(...)
  super

  # Remove prefix
  @function = @input.sub("transform.", "")

  raise Error::InvalidTransformFunctionError.new(input, TRANSFORM_METHODS) unless TRANSFORM_METHODS.include?(function)

  prepare_arguments
end

Instance Attribute Details

#functionString (readonly)

Returns The transformation function name.

Returns:

  • (String)

    The transformation function name



32
33
34
# File 'lib/spec_forge/attribute/transform.rb', line 32

def function
  @function
end

Instance Method Details

#valueObject

Returns the result of applying the transformation function

Returns:

  • (Object)

    The transformed value



57
58
59
# File 'lib/spec_forge/attribute/transform.rb', line 57

def value
  # Noop
end