Class: PictureHandler::Uploader::Base
- Inherits:
-
Object
- Object
- PictureHandler::Uploader::Base
- Includes:
- ImgVersion, MiniMagick
- Defined in:
- lib/picture_handler/uploader/base.rb
Instance Attribute Summary collapse
-
#image ⇒ Object
Returns the value of attribute image.
-
#model ⇒ Object
Returns the value of attribute model.
-
#real_filename ⇒ Object
readonly
Returns the value of attribute real_filename.
-
#versions ⇒ Object
Returns the value of attribute versions.
Instance Method Summary collapse
- #delete_all ⇒ Object
- #filename ⇒ Object
-
#info ⇒ Object
—————————– # —— Public Method ——– # —————————– #.
-
#initialize(model = nil) ⇒ Base
constructor
A new instance of Base.
- #remote_path ⇒ Object
-
#store ⇒ Object
When a Model.save is done.
- #store_dir ⇒ Object
- #versions_info ⇒ Object
Methods included from ImgVersion
Methods included from MiniMagick
Constructor Details
#initialize(model = nil) ⇒ Base
Returns a new instance of Base.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/picture_handler/uploader/base.rb', line 13 def initialize(model=nil) # Set once @image = nil @model = model @versions = {} register_versions # Changing runtime @current_version = nil @info_built = false @infos = {} @real_filename end |
Instance Attribute Details
#image ⇒ Object
Returns the value of attribute image.
10 11 12 |
# File 'lib/picture_handler/uploader/base.rb', line 10 def image @image end |
#model ⇒ Object
Returns the value of attribute model.
10 11 12 |
# File 'lib/picture_handler/uploader/base.rb', line 10 def model @model end |
#real_filename ⇒ Object (readonly)
Returns the value of attribute real_filename.
11 12 13 |
# File 'lib/picture_handler/uploader/base.rb', line 11 def real_filename @real_filename end |
#versions ⇒ Object
Returns the value of attribute versions.
10 11 12 |
# File 'lib/picture_handler/uploader/base.rb', line 10 def versions @versions end |
Instance Method Details
#delete_all ⇒ Object
70 71 72 |
# File 'lib/picture_handler/uploader/base.rb', line 70 def delete_all delete_all_with_file_system end |
#filename ⇒ Object
27 28 29 |
# File 'lib/picture_handler/uploader/base.rb', line 27 def filename "unamed" end |
#info ⇒ Object
—————————– # —— Public Method ——– # —————————– #
52 53 54 55 |
# File 'lib/picture_handler/uploader/base.rb', line 52 def info build_infos unless @info_built @infos end |
#remote_path ⇒ Object
35 36 37 |
# File 'lib/picture_handler/uploader/base.rb', line 35 def remote_path nil end |
#store ⇒ Object
When a Model.save is done
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/picture_handler/uploader/base.rb', line 58 def store # Get the filename once and will use the same for all futur save @real_filename = filename # Is the model new ? delete old record if true delete_all if @model.old_record process_original_image apply_versions end |
#store_dir ⇒ Object
31 32 33 |
# File 'lib/picture_handler/uploader/base.rb', line 31 def store_dir "public/ph_pictures/" end |
#versions_info ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/picture_handler/uploader/base.rb', line 39 def versions_info res = info res = res.select do |obj| obj == :position || (res[:versions].include? obj) end res end |