Module: Card::Set::Abstract::Attachment::StorageType
- Extended by:
- Card::Set
- Defined in:
- platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb
Overview
Set: Abstract (Attachment, StorageType)
Constant Summary
Constants included
from Helpers
Helpers::SET_PATTERN_TEST_REGEXP
Constants included
from Event::Api
Event::Api::OPTIONS
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Card::Set
reset
Methods included from I18nScope
#mod_name, #scope
Methods included from Registrar
#extended, #finalize_load, #process_base_modules, #register_set
Methods included from Helpers
#format_module, #format_modules, #method_missing, #modules, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscored_name
#assign_type, #attachment, #define_set_from_error, #ensure_set, #setting_opts, #stage_method
Methods included from Format
#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name
#include_set, #include_set_formats
Methods included from Trait
#card_accessor, #card_reader, #card_writer, #require_field
Methods included from Event::Api
#event
Instance Attribute Details
#bucket=(value) ⇒ Object
Sets the attribute bucket
8
9
10
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 8
def bucket=(value)
@bucket = value
end
|
#new_storage_type=(value) ⇒ Object
Sets the attribute new_storage_type
8
9
10
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 8
def new_storage_type=(value)
@new_storage_type = value
end
|
Class Method Details
.source_location ⇒ Object
7
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 7
def self.source_location; "/Users/ethan/dev/decko/gem/mod/carrierwave/set/abstract/attachment/01_storage_type.rb"; end
|
Instance Method Details
#cloud? ⇒ Boolean
27
28
29
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 27
def cloud?
storage_type == :cloud
end
|
#coded? ⇒ Boolean
39
40
41
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 39
def coded?
storage_type == :coded
end
|
19
20
21
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 19
def current
@current ||= refresh true
end
|
#event: update_storage ⇒ Object
10
11
12
13
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 10
event :update_storage, :store, on: :update, when: :storage_changed? do
send "#{attachment_name}=", current.attachment.file unless @attaching
write_identifier
end
|
#event: validate_storage_type ⇒ Object
15
16
17
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 15
event :validate_storage_type, :validate, on: :save do
errors.add :storage_type, unknown_storage_type unless known_storage_type?
end
|
#file_updated_at ⇒ Object
70
71
72
73
74
75
76
77
78
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 70
def file_updated_at
if coded?
File.mtime file.path
else
updated_at
end
rescue Errno::ENOENT nil
end
|
#known_storage_type? ⇒ Boolean
62
63
64
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 62
def known_storage_type?
storage_type.in? CarrierWave::FileCardUploader::STORAGE_TYPES
end
|
#local? ⇒ Boolean
35
36
37
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 35
def local?
storage_type == :local
end
|
#read_only? ⇒ Boolean
23
24
25
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 23
def read_only?
web? || (cloud? && bucket_config[:read_only])
end
|
#remote_storage? ⇒ Boolean
43
44
45
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 43
def remote_storage?
cloud? || web?
end
|
#storage_changed? ⇒ Boolean
56
57
58
59
60
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 56
def storage_changed?
(storage_type != current.storage_type) ||
(bucket != current.bucket) ||
(mod != current.mod)
end
|
#storage_type ⇒ Object
52
53
54
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 52
def storage_type
@storage_type ||= new_card? ? storage_type_from_config : storage_type_from_content
end
|
#storage_type=(value) ⇒ Object
47
48
49
50
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 47
def storage_type= value
@explicit_storage_type = true
@storage_type = value&.to_sym
end
|
#unknown_storage_type ⇒ Object
66
67
68
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 66
def unknown_storage_type
t :carrierwave_unknown_storage_type, new_storage_type: storage_type
end
|
#web? ⇒ Boolean
31
32
33
|
# File 'platypus/tmp/set/gem-defaults/mod016-carrierwave/abstract/attachment/01_storage_type.rb', line 31
def web?
storage_type == :web
end
|