Class: EasyTalk::Builders::StringBuilder
- Inherits:
-
BaseBuilder
- Object
- BaseBuilder
- EasyTalk::Builders::StringBuilder
- Extended by:
- T::Sig
- Defined in:
- lib/easy_talk/builders/string_builder.rb
Overview
Builder class for string properties.
Direct Known Subclasses
Constant Summary collapse
- VALID_OPTIONS =
{ format: { type: String, key: :format }, pattern: { type: String, key: :pattern }, min_length: { type: Integer, key: :minLength }, max_length: { type: Integer, key: :maxLength }, enum: { type: T::Array[String], key: :enum }, const: { type: String, key: :const }, default: { type: String, key: :default } }.freeze
Constants inherited from BaseBuilder
Instance Attribute Summary
Attributes inherited from BaseBuilder
#options, #property_name, #schema
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(name, constraints = {}) ⇒ StringBuilder
constructor
A new instance of StringBuilder.
Methods inherited from BaseBuilder
Constructor Details
#initialize(name, constraints = {}) ⇒ StringBuilder
Returns a new instance of StringBuilder.
24 25 26 |
# File 'lib/easy_talk/builders/string_builder.rb', line 24 def initialize(name, constraints = {}) super(name, { type: 'string' }, constraints, VALID_OPTIONS) end |
Instance Method Details
#build ⇒ Object
28 29 30 31 32 33 |
# File 'lib/easy_talk/builders/string_builder.rb', line 28 def build super.tap do |schema| pattern = schema[:pattern] schema[:pattern] = JsRegex.new(pattern).source if pattern.is_a?(String) end end |