Class: SpecForge::Attribute::Generate
- Inherits:
-
Parameterized
- Object
- Attribute
- Parameterized
- SpecForge::Attribute::Generate
- Defined in:
- lib/spec_forge/attribute/generate.rb
Overview
Represents an attribute that generates data structures dynamically.
This class provides generation functions like array that can create
collections of arbitrary size with evaluated values. It's useful for
testing batch endpoints or generating large payloads.
Constant Summary collapse
- KEYWORD_REGEX =
Regular expression pattern that matches attribute keywords with this prefix. Used for identifying this attribute type during parsing. Matches case-insensitively (generate., GENERATE., Generate., etc.)
/^generate\./i- METHODS =
The available generation methods
%w[ array ].freeze
Instance Attribute Summary collapse
-
#function ⇒ String
readonly
The generation function name (e.g., "array").
Attributes inherited from Parameterized
Instance Method Summary collapse
-
#initialize ⇒ Generate
constructor
Creates a new generate attribute with the specified function and arguments.
-
#value ⇒ Object
Returns the result of applying the generation function.
Methods inherited from Parameterized
Constructor Details
#initialize ⇒ Generate
Creates a new generate attribute with the specified function and arguments
66 67 68 69 70 71 72 73 |
# File 'lib/spec_forge/attribute/generate.rb', line 66 def initialize(...) super @function = @input.sub(KEYWORD_REGEX, "") raise Error::InvalidGenerateFunctionError.new(input, METHODS) unless METHODS.include?(function) prepare_arguments end |
Instance Attribute Details
#function ⇒ String (readonly)
The generation function name (e.g., "array")
57 58 59 |
# File 'lib/spec_forge/attribute/generate.rb', line 57 def function @function end |
Instance Method Details
#value ⇒ Object
Returns the result of applying the generation function
80 81 82 83 84 85 |
# File 'lib/spec_forge/attribute/generate.rb', line 80 def value case function when "array" generate_array end end |