Module: Axn::FieldDeclarations
- Defined in:
- lib/axn/field_declarations.rb
Overview
Normalizes the flexible expects:/exposes: declaration formats into a
uniform { field => opts_hash } shape. Accepts an already-built Hash (passed
through untouched), or an Array whose elements are either bare field names
(Symbol/String, hydrated to empty opts) or Hashes of field => opts.
Shared so callers building Axn classes outside Factory (e.g. adapters that define #call themselves rather than routing a callable through Factory) can reuse the exact same normalization instead of duplicating it.
Class Method Summary collapse
Class Method Details
.hydrate(declarations) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/axn/field_declarations.rb', line 15 def hydrate(declarations) return declarations if declarations.is_a?(Hash) Array(declarations).each_with_object({}) do |item, acc| if item.is_a?(Hash) item.each { |k, v| acc[k] = v } else acc[item] = {} end end end |