Class: SpecForge::Attribute::Parameterized
- Inherits:
-
Attribute
- Object
- Attribute
- SpecForge::Attribute::Parameterized
- Defined in:
- lib/spec_forge/attribute/parameterized.rb
Overview
Base class for attributes that support positional and keyword arguments
This class provides the foundation for attributes that need to accept arguments, such as Faker, Matcher, and Factory. It handles both positional (array-style) and keyword (hash-style) arguments.
Instance Attribute Summary collapse
-
#arguments ⇒ Hash{Symbol => Object}
readonly
A hash containing both positional and keyword arguments for this attribute The hash has two keys: :positional (Array) and :keyword (Hash).
Class Method Summary collapse
-
.from_hash(hash, **options) ⇒ Parameterized
Creates a new attribute instance from a hash representation.
Instance Method Summary collapse
-
#initialize ⇒ Parameterized
constructor
Creates a new parameterized attribute with the specified arguments.
Constructor Details
#initialize ⇒ Parameterized
Creates a new parameterized attribute with the specified arguments
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/spec_forge/attribute/parameterized.rb', line 70 def initialize(...) super @input = @input.to_s.downcase @arguments = { positional: @options[:positional] || [], keyword: @options[:keyword] || {} } @options.clear # No need to store a duplicate end |
Instance Attribute Details
#arguments ⇒ Hash{Symbol => Object} (readonly)
A hash containing both positional and keyword arguments for this attribute The hash has two keys: :positional (Array) and :keyword (Hash)
60 61 62 |
# File 'lib/spec_forge/attribute/parameterized.rb', line 60 def arguments @arguments end |
Class Method Details
.from_hash(hash, **options) ⇒ Parameterized
Creates a new attribute instance from a hash representation
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/spec_forge/attribute/parameterized.rb', line 33 def self.from_hash(hash, **) = hash.first input = .first arguments = .second case arguments when Array new(input, positional: arguments, **) when Hash new(input, keyword: arguments, **) else # Single value new(input, positional: [arguments], **) end end |