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.
170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/html2rss/config/schema.rb', line 170 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.
185 186 187 |
# File 'lib/html2rss/config/schema.rb', line 185 def stringify_hash(object) object.to_h { |key, value| [key.to_s, call(value)] } end |