Module: Card::Set::Abstract::Attachment
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod015-carrierwave/abstract/attachment.rb,
tmpsets/set/mod015-carrierwave/abstract/attachment/paths.rb,
tmpsets/set/mod015-carrierwave/abstract/attachment/storage_type.rb,
tmpsets/set/mod015-carrierwave/abstract/attachment/upload_cache.rb
Defined Under Namespace
Modules: Paths, StorageType, UploadCache
Constant Summary
Constants included from Format
Instance Attribute Summary collapse
-
#empty_ok ⇒ Object
writeonly
Sets the attribute empty_ok.
Class Method Summary collapse
Instance Method Summary collapse
- #assign_set_specific_attributes ⇒ Object
- #attachment_changed? ⇒ Boolean
- #attachment_format(ext) ⇒ Object
- #create_versions? ⇒ Boolean
- #delete_files_for_action(action) ⇒ Object
- #empty_ok? ⇒ Boolean
- #file_ready_to_save? ⇒ Boolean
-
#item_names(_args = {}) ⇒ Object
needed for flexmail attachments.
- #original_filename ⇒ Object
-
#rollback_to(action) ⇒ Object
create filesystem links to files from prior action.
- #unfilled? ⇒ Boolean
Methods included from I18nScope
Methods included from Loader
#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set
Methods included from Helpers
#abstract_set?, #all_set?, #num_set_parts, #shortname
Methods included from Card::Set::AdvancedApi
#attachment, #ensure_set, #stage_method
Methods included from Format
#all_set_format_mod!, #before, #define_on_format, #format, #register_set_format, #view, #view_for_override
Methods included from Inheritance
#include_set, #include_set_formats
Methods included from Basket
#abstract_basket, #add_to_basket, #basket
Methods included from Trait
#card_accessor, #card_reader, #card_writer
Methods included from Event::Api
Instance Attribute Details
#empty_ok=(value) ⇒ Object (writeonly)
Sets the attribute empty_ok
6 7 8 |
# File 'tmpsets/set/mod015-carrierwave/abstract/attachment.rb', line 6 def empty_ok=(value) @empty_ok = value end |
Class Method Details
.included(host_class) ⇒ Object
8 9 10 |
# File 'tmpsets/set/mod015-carrierwave/abstract/attachment.rb', line 8 def self.included host_class host_class.extend CarrierWave::CardMount end |
Instance Method Details
#assign_set_specific_attributes ⇒ Object
77 78 79 80 81 82 83 |
# File 'tmpsets/set/mod015-carrierwave/abstract/attachment.rb', line 77 def assign_set_specific_attributes # reset content if we really have something to upload if @set_specific.present? && @set_specific[.to_s].present? self.content = nil end super end |
#attachment_changed? ⇒ Boolean
65 66 67 |
# File 'tmpsets/set/mod015-carrierwave/abstract/attachment.rb', line 65 def send "#{}_changed?" end |
#attachment_format(ext) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'tmpsets/set/mod015-carrierwave/abstract/attachment.rb', line 99 def ext if ext.present? && && (original_ext = .extension) if ["file", original_ext].member? ext original_ext elsif (exts = MIME::Types[.content_type]) if exts.find { |mt| mt.extensions.member? ext } ext else exts[0].extensions[0] end end end rescue => e Rails.logger.info "attachment_format issue: #{e.}" nil end |
#create_versions? ⇒ Boolean
69 70 71 |
# File 'tmpsets/set/mod015-carrierwave/abstract/attachment.rb', line 69 def create_versions? true end |
#delete_files_for_action(action) ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'tmpsets/set/mod015-carrierwave/abstract/attachment.rb', line 85 def delete_files_for_action action with_selected_action_id(action.id) do .file.delete .versions.each_value do |version| version.file.delete end end end |
#empty_ok? ⇒ Boolean
73 74 75 |
# File 'tmpsets/set/mod015-carrierwave/abstract/attachment.rb', line 73 def empty_ok? @empty_ok end |
#file_ready_to_save? ⇒ Boolean
44 45 46 47 48 49 |
# File 'tmpsets/set/mod015-carrierwave/abstract/attachment.rb', line 44 def file_ready_to_save? .file.present? && !preliminary_upload? && !save_preliminary_upload? && end |
#item_names(_args = {}) ⇒ Object
needed for flexmail attachments. hacky.
51 52 53 |
# File 'tmpsets/set/mod015-carrierwave/abstract/attachment.rb', line 51 def item_names _args={} # needed for flexmail attachments. hacky. [cardname] end |
#original_filename ⇒ Object
55 56 57 58 |
# File 'tmpsets/set/mod015-carrierwave/abstract/attachment.rb', line 55 def original_filename return content.split("/").last if web? .original_filename end |
#rollback_to(action) ⇒ Object
create filesystem links to files from prior action
95 96 97 |
# File 'tmpsets/set/mod015-carrierwave/abstract/attachment.rb', line 95 def rollback_to action update_attributes! revision(action).merge(empty_ok: true) end |
#unfilled? ⇒ Boolean
60 61 62 63 |
# File 'tmpsets/set/mod015-carrierwave/abstract/attachment.rb', line 60 def unfilled? !.present? && !save_preliminary_upload? && !subcards.present? && !content.present? end |