diff --git a/app/models/learning_object.rb b/app/models/learning_object.rb index 4f859710a7a3e8c52c70ad19758f7e7a302b9b49..be71c8daa093df88fd7cfa1006d0158f46d85f57 100644 --- a/app/models/learning_object.rb +++ b/app/models/learning_object.rb @@ -1,14 +1,37 @@ class LearningObject include ActiveModel::Model - attr_accessor :id, :id_dspace, :title, :description, :date_creation, - :thumbnail, :metadata + attr_accessor :id, + :name, :description, :thumbnail, :date_creation, :last_modified, + :id_dspace, :type, :bitstreams, :metadata attr_accessor :likes, :views + def initialize args + @id = args[:id] + + @name = args[:name] || '' + @description = args[:description] || '' + @thumbnail = args[:thumbnail] || '' + @date_creation = args[:date_creation] || '' + + @id_dspace = args[:id_dspace] || '' + @type = args[:type] || '' + @bitstreams = args[:bitstreams] || [] + @metadata = args[:metadata] || [] + @last_modified = args[:last_modified] || '' + end + def subjects @subjects ||= learning_object_repository.get_subjects(self) end + def get_metadata_value_of key + values = @metadata.select { |v| v["key"] == key } + unless values.empty? + return values.first["value"] + end + end + private def learning_object_repository