Class: SpecForge::Attribute::Transform
- Inherits:
-
Parameterized
- Object
- Attribute
- Parameterized
- SpecForge::Attribute::Transform
- 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
/^transform\./i- TRANSFORM_METHODS =
The available transformation methods
%w[].freeze
Instance Attribute Summary collapse
-
#function ⇒ String
readonly
The transformation function name.
Attributes inherited from Parameterized
Instance Method Summary collapse
-
#initialize ⇒ Transform
constructor
Creates a new transform attribute with the specified function and arguments.
-
#value ⇒ Object
Returns the result of applying the transformation function.
Methods inherited from Parameterized
Constructor Details
#initialize ⇒ Transform
Creates a new transform attribute with the specified function and arguments
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
#function ⇒ String (readonly)
Returns The transformation function name.
32 33 34 |
# File 'lib/spec_forge/attribute/transform.rb', line 32 def function @function end |
Instance Method Details
#value ⇒ Object
Returns the result of applying the transformation function
57 58 59 |
# File 'lib/spec_forge/attribute/transform.rb', line 57 def value # Noop end |