From f8d47890cb2cbb6b757f62d8e56b8d0124f0667d Mon Sep 17 00:00:00 2001
From: Mauricio Giacomini Girardello <mgg12@inf.ufpr.br>
Date: Mon, 18 Jan 2016 11:09:36 -0200
Subject: [PATCH] refactoring attachment model of learning objects

---
 app/models/learning_object/attachment.rb | 32 ++----------------------
 1 file changed, 2 insertions(+), 30 deletions(-)

diff --git a/app/models/learning_object/attachment.rb b/app/models/learning_object/attachment.rb
index ea56409f..a40cb335 100644
--- a/app/models/learning_object/attachment.rb
+++ b/app/models/learning_object/attachment.rb
@@ -1,32 +1,4 @@
 class LearningObject::Attachment
-  attr_accessor :bitstreams
-
-  def initialize(bitstreams)
-    @bitstreams = bitstreams
-  end
-
-  def get_retrievelink
-    get_bitstream_retrievelink_of "ORIGINAL"
-  end
-
-  def get_filename
-    get_bitstream_filename_of "ORIGINAL"
-  end
-
-  private
-
-  def get_bitstream_retrievelink_of name
-    values = @bitstreams.select { |v| v["bundleName"] == name }
-    unless values.empty?
-      return "#{DspaceService.link}#{values.first["retrieveLink"]}"
-    end
-  end
-
-  def get_bitstream_filename_of name
-    values = @bitstreams.select { |v| v["bundleName"] == name }
-    unless values.empty?
-      return values.first["name"]
-    end
-  end
-
+  include ActiveModel::Model
+  attr_accessor :id, :name, :link, :retrieve_link, :description, :format, :mime_type, :size
 end
-- 
GitLab