Class: SpecForge::Normalizer::Structure
- Inherits:
-
Hash
- Object
- Hash
- SpecForge::Normalizer::Structure
- Defined in:
- lib/spec_forge/normalizer/structure.rb
Overview
Represents a parsed structure definition for normalization
Structure definitions specify the expected shape of input data, including types, defaults, aliases, and nested structures. They are loaded from YAML files and normalized themselves.
Constant Summary collapse
- STRUCTURE =
Meta-structure defining the format of structure definitions
{ type: { type: [String, Array, Class], default: nil, # Important to default this to nil so other logic can handle it required: true, validator: :present? }, default: { type: [String, NilClass, Numeric, Array, Hash, TrueClass, FalseClass] }, required: { type: [TrueClass, FalseClass] }, aliases: { type: Array, structure: {type: String} }, structure: { type: Hash }, validator: { type: String }, transformer: { type: String }, description: { type: String }, examples: { type: Array, structure: { type: [String, Integer, Float, Hash, Array, TrueClass, FalseClass] } } }.freeze
Instance Attribute Summary collapse
-
#label ⇒ String
readonly
Human-readable label for this structure.
Instance Method Summary collapse
-
#initialize(input, label: "") ⇒ Structure
constructor
Creates a new Structure from the given input definition.
Constructor Details
#initialize(input, label: "") ⇒ Structure
Creates a new Structure from the given input definition
64 65 66 67 68 69 70 71 72 |
# File 'lib/spec_forge/normalizer/structure.rb', line 64 def initialize(input, label: "") @label = label # Pull in the data deep_merge!(input) # And normalize normalize end |
Instance Attribute Details
#label ⇒ String (readonly)
Returns Human-readable label for this structure.
54 55 56 |
# File 'lib/spec_forge/normalizer/structure.rb', line 54 def label @label end |