Sha256: 639c3940a8231fb14fedd42cca469bdfdc49fa88cabf715dad2e5a2c420d94d0

Contents?: true

Size: 559 Bytes

Versions: 3

Compression:

Stored size: 559 Bytes

Contents

module Attributor
  class String
    include Type

    def self.native_type
      return ::String
    end

    def self.load(value,context=Attributor::DEFAULT_ROOT_CONTEXT, **options)
      if value.kind_of?(Enumerable)
        raise IncompatibleTypeError,  context: context, value_type: value.class, type: self
      end

      value && String(value)
    rescue
      super
    end

    def self.example(context=nil, options:{})
      if options[:regexp]
        return options[:regexp].gen
      else
        return /\w+/.gen
      end
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
attributor-2.6.0 lib/attributor/types/string.rb
attributor-2.5.0 lib/attributor/types/string.rb
attributor-2.4.0 lib/attributor/types/string.rb