lib/immoscout/models/actions/attachment.rb in immoscout-1.3.2 vs lib/immoscout/models/actions/attachment.rb in immoscout-1.4.0
- old
+ new
@@ -6,10 +6,11 @@
# rubocop:disable Metrics/BlockLength because this is how an ActiveSupport
# concern looks like
module Immoscout
module Models
module Actions
+ # Actions to work with attachments.
module Attachment
extend ActiveSupport::Concern
included do
include Immoscout::Models::Concerns::Modelable
@@ -52,11 +53,11 @@
)
handle_response(response)
self
end
- private
+ protected
def file_extension
File.extname(file_name)
end
@@ -78,21 +79,19 @@
'.png' => 'image/png',
'.pdf' => 'application/pdf'
}.fetch(ext)
end
- # rubocop:disable Metrics/AbcSize because of the mapping logic
def all(real_estate_id)
response = api.get(
"user/#{api.user_name}/realestate/#{real_estate_id}/attachment"
)
handle_response(response)
objects = unpack_collection.call(response.body)
objects
.map { |object| new(object) }
.select { |object| object.type =~ /#{name.demodulize}/i }
end
- # rubocop:enable Metrics/AbcSize
end
end
end
end
end