Class: Exwiw::MaskValue
- Inherits:
-
Serdes::TypeBase
- Object
- Serdes::TypeBase
- Exwiw::MaskValue
- Defined in:
- lib/exwiw/mask_value.rb
Overview
Serdes type for a replace_with value: a template String with {column}
placeholders, rendered as text, or a non-String JSON scalar used verbatim so
a column that is not text keeps its type (in MongoDB, its BSON type).
Constant Summary collapse
- PERMITTED =
[String, Integer, Float].freeze
- PLACEHOLDER =
What counts as a
{column}placeholder: an empty brace pair names no column, which is what lets{}be an empty-JSON mask. One definition, shared by the adapters that parse a template and the generator that must avoid emitting one — keep it capture-free, since the splitter'sscanreads whole matches. /\{[^{}]+\}/
Class Method Summary collapse
-
.scalar?(value) ⇒ Boolean
Whether
valueis used verbatim rather than rendered as a template.
Instance Method Summary collapse
Class Method Details
.scalar?(value) ⇒ Boolean
Whether value is used verbatim rather than rendered as a template.
22 23 24 |
# File 'lib/exwiw/mask_value.rb', line 22 def self.scalar?(value) !value.is_a?(String) && !value.nil? end |
Instance Method Details
#permit?(value) ⇒ Boolean
17 18 19 |
# File 'lib/exwiw/mask_value.rb', line 17 def permit?(value) value == true || value == false || PERMITTED.any? { |type| value.is_a?(type) } end |
#to_s ⇒ Object
26 27 28 |
# File 'lib/exwiw/mask_value.rb', line 26 def to_s "mask_value" end |