Sha256: ee9a10a67732e02ec17e819dfca215ab7d6ae2ae5a218319fdcbe2f82abc0e7a

Contents?: true

Size: 655 Bytes

Versions: 33

Compression:

Stored size: 655 Bytes

Contents

module Quby
  module Questionnaires
    module Entities
      class Validation
        attr_reader :config

        def initialize(config)
          @config = config
        end

        def type
          config[:type]
        end

        def as_json
          case type
          when :regexp
            valc = config.clone
            valc[:matcher] = valc[:matcher].source.to_s

            # Replace single backslashes with two backslashes
            valc[:matcher].gsub!("\\", "\\\\")

            valc
          else
            config
          end.deep_transform_keys{ |key| key.to_s.camelize(:lower) }
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
quby-5.6.5 lib/quby/questionnaires/entities/validation.rb
quby-5.6.3 lib/quby/questionnaires/entities/validation.rb
quby-5.6.2 lib/quby/questionnaires/entities/validation.rb
quby-5.6.1 lib/quby/questionnaires/entities/validation.rb
quby-5.6.0 lib/quby/questionnaires/entities/validation.rb
quby-5.5.0 lib/quby/questionnaires/entities/validation.rb
quby-5.4.0 lib/quby/questionnaires/entities/validation.rb
quby-5.3.1 lib/quby/questionnaires/entities/validation.rb
quby-5.3.0 lib/quby/questionnaires/entities/validation.rb
quby-5.2.0 lib/quby/questionnaires/entities/validation.rb
quby-5.1.3 lib/quby/questionnaires/entities/validation.rb
quby-5.1.2 lib/quby/questionnaires/entities/validation.rb
quby-5.1.1 lib/quby/questionnaires/entities/validation.rb
quby-5.1.0 lib/quby/questionnaires/entities/validation.rb
quby-5.0.5 lib/quby/questionnaires/entities/validation.rb
quby-5.0.4 lib/quby/questionnaires/entities/validation.rb
quby-5.0.3 lib/quby/questionnaires/entities/validation.rb
quby-5.0.2 lib/quby/questionnaires/entities/validation.rb
quby-5.0.1 lib/quby/questionnaires/entities/validation.rb
quby-5.0.0 lib/quby/questionnaires/entities/validation.rb