Module: Html2rss::Config::Schema::DeepStringifier
- Defined in:
- lib/html2rss/config/schema.rb
Overview
Converts nested hash keys to strings so the resulting schema serializes cleanly.
Class Method Summary collapse
-
.call(object) ⇒ Hash, ...
Deep copy with stringified hash keys.
-
.stringify_hash(object) ⇒ Hash{String => Object}
Hash with recursively normalized values.
Class Method Details
.call(object) ⇒ Hash, ...
Returns deep copy with stringified hash keys.
219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/html2rss/config/schema.rb', line 219 def call(object) case object when Hash stringify_hash(object) when Array object.map { |value| call(value) } when Symbol object.to_s else object end end |
.stringify_hash(object) ⇒ Hash{String => Object}
Returns hash with recursively normalized values.
234 235 236 |
# File 'lib/html2rss/config/schema.rb', line 234 def stringify_hash(object) object.to_h { |key, value| [key.to_s, call(value)] } end |