Class: LadyJosephine::Image
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- LadyJosephine::Image
- Defined in:
- app/models/lady_josephine/image.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.allowed_class_name(uploadable_type) ⇒ Object
31 32 33 |
# File 'app/models/lady_josephine/image.rb', line 31 def self.allowed_class_name(uploadable_type) uploadable_type.classify if LadyJosephine::Whitelist.instance.is_whitelisted?(uploadable_type) end |
.from_params(params) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/lady_josephine/image.rb', line 11 def self.from_params(params) uploadable_type = allowed_class_name params["model-name"] return nil if uploadable_type.nil? uploadable_uuid = params["article-uuid"] uploadable_attribute = params["column-name"] uploadable_id = uploadable_type.constantize.find_by(lady_josephine_server_uuid: uploadable_uuid).try :id block_uuid = params["block-uuid"] file = params[:attachment][:file] new( block_uuid: block_uuid, uploadable_type: uploadable_type, uploadable_uuid: uploadable_uuid, uploadable_id: uploadable_id, uploadable_attribute: uploadable_attribute, file: file ) end |
Instance Method Details
#update_file_metadata ⇒ Object
35 36 37 38 39 |
# File 'app/models/lady_josephine/image.rb', line 35 def if file.present? && file? self. = file..to_json end end |