Class: Attributor::String

Inherits:
Object
  • Object
show all
Includes:
Type
Defined in:
lib/attributor/types/string.rb

Class Method Summary collapse

Methods included from Type

included

Class Method Details

.example(context = nil, options: {}) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/attributor/types/string.rb', line 16

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

.load(value, context = Attributor::DEFAULT_ROOT_CONTEXT, **options) ⇒ Object



10
11
12
13
14
# File 'lib/attributor/types/string.rb', line 10

def self.load(value,context=Attributor::DEFAULT_ROOT_CONTEXT, **options)
  String(value)
rescue
  super
end

.native_typeObject



5
6
7
# File 'lib/attributor/types/string.rb', line 5

def self.native_type
  return ::String
end