Class: Attributor::Tempfile
- Inherits:
-
Object
- Object
- Attributor::Tempfile
show all
- Includes:
- Type
- Defined in:
- lib/attributor/types/tempfile.rb
Class Method Summary
collapse
Methods included from Type
get_memoized_collection_class, set_memoized_collection_class
Class Method Details
.dump(value, **_opts) ⇒ Object
19
20
21
|
# File 'lib/attributor/types/tempfile.rb', line 19
def self.dump(value, **_opts)
value && value.read
end
|
.example(context = Attributor::DEFAULT_ROOT_CONTEXT, options: {}) ⇒ Object
38
39
40
|
# File 'lib/attributor/types/tempfile.rb', line 38
def self.family
String.family
end
|
.json_schema_type ⇒ Object
42
43
44
|
# File 'lib/attributor/types/tempfile.rb', line 42
def self.json_schema_type
:string
end
|
.load(value, context = Attributor::DEFAULT_ROOT_CONTEXT, **options) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/attributor/types/tempfile.rb', line 23
def self.load(value, context = Attributor::DEFAULT_ROOT_CONTEXT, **options)
case value
when ::String
name = Attributor.humanize_context(context)
file = ::Tempfile.new(name)
file.write(value)
file.rewind
return file
end
super
end
|
.native_type ⇒ Object
7
8
9
|
# File 'lib/attributor/types/tempfile.rb', line 7
def self.native_type
::Tempfile
end
|