DB restructure, print page
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
class ImageProcessor
|
||||
ALLOWED_LOGO_TYPES = ['Network', 'Employer'].freeze
|
||||
|
||||
def initialize(image_path, new_filename = nil)
|
||||
def initialize(image_path, logo_type, new_filename = nil)
|
||||
@image_path = image_path
|
||||
@logo_type = logo_type.capitalize
|
||||
@new_filename = new_filename
|
||||
|
||||
unless ALLOWED_LOGO_TYPES.include?(@logo_type)
|
||||
raise ArgumentError, "Invalid logo type: #{@logo_type}. Must be one of: #{ALLOWED_LOGO_TYPES.join(', ')}"
|
||||
end
|
||||
end
|
||||
|
||||
def call
|
||||
@@ -17,11 +23,11 @@ class ImageProcessor
|
||||
# binary_data = File.open(@image_path, 'rb').read
|
||||
meme_type = Marcel::MimeType.for Pathname.new(@image_path)
|
||||
|
||||
CardLogoFile.create(
|
||||
filename: filename,
|
||||
image_data: binary_data,
|
||||
content_type: meme_type,
|
||||
logo_type: "employer"
|
||||
)
|
||||
logo_model = "IdCard::#{@logo_type}Logo".constantize
|
||||
|
||||
logo_model.find_or_create_by(filename: filename) do |logo|
|
||||
logo.image_data = binary_data
|
||||
logo.content_type = meme_type
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user