Class: Netfira::WebConnect::Model::Record::FileRecord
Constant Summary
Constants included
from Serializer
Serializer::EXCLUDE_FROM_SERIALIZE
Class Method Summary
collapse
Instance Method Summary
collapse
#as_readonly, find_by_origin_id, find_or_create_by_origin_id, find_or_initialize_by_origin_id, has_file?, has_languages?, #origin_id, #reload, schema, sendable?, tree?, writable?, #write_with_type_casting
#materialize
Methods included from Digests
#digest
Methods included from Serializer
#to_s
Methods included from Relations
#relate, #unrelate
plural_name, single_name
Class Method Details
.origin_key ⇒ Object
21
22
23
|
# File 'lib/netfira/web_connect/model/record/file_record.rb', line 21
def origin_key
:file_name
end
|
.table_name ⇒ Object
17
18
19
|
# File 'lib/netfira/web_connect/model/record/file_record.rb', line 17
def table_name
self == Model::Record::FileRecord ? Models::Table.table_name : super
end
|
Instance Method Details
#<<(input) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/netfira/web_connect/model/record/file_record.rb', line 29
def <<(input)
if input.is_a? Model::Record
super input
else
self.data = input
end
end
|
#attachment_file_name ⇒ Object
57
58
59
|
# File 'lib/netfira/web_connect/model/record/file_record.rb', line 57
def attachment_file_name
file_name
end
|
#attachment_file_name=(value) ⇒ Object
61
62
63
|
# File 'lib/netfira/web_connect/model/record/file_record.rb', line 61
def attachment_file_name=(value)
self.file_name = value
end
|
#attachment_file_size ⇒ Object
65
66
67
|
# File 'lib/netfira/web_connect/model/record/file_record.rb', line 65
def attachment_file_size
size
end
|
#attachment_file_size=(value) ⇒ Object
69
70
71
|
# File 'lib/netfira/web_connect/model/record/file_record.rb', line 69
def attachment_file_size=(value)
self.size = value
end
|
#checksum ⇒ Object
37
38
39
40
|
# File 'lib/netfira/web_connect/model/record/file_record.rb', line 37
def checksum
bin = self[:checksum]
@checksum ||= bin && Checksum.new(bin)
end
|
#checksum=(value) ⇒ Object
42
43
44
45
|
# File 'lib/netfira/web_connect/model/record/file_record.rb', line 42
def checksum=(value)
@checksum = nil
self[:checksum] = Checksum === value ? value.b : value
end
|
#data ⇒ Object
47
48
49
|
# File 'lib/netfira/web_connect/model/record/file_record.rb', line 47
def data
attachment.present? ? Paperclip.io_adapters.for(attachment) : nil
end
|
#data=(value) ⇒ Object
51
52
53
54
55
|
# File 'lib/netfira/web_connect/model/record/file_record.rb', line 51
def data=(value)
self.attachment = value
value.rewind
self.checksum = Checksum.of(value.read)
end
|