Commit 21c5e5de authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

move repeated build method from entities for HashBuilder module

parent d694a60b
module Dspace module Dspace
class Bitstream class Bitstream
include Dspace::Builders::HashBuilder
attr_accessor :name, :bundle_name, attr_accessor :name, :bundle_name,
:description, :format, :mime_type :description, :format, :mime_type
......
...@@ -2,13 +2,19 @@ module Dspace ...@@ -2,13 +2,19 @@ module Dspace
module Builders module Builders
module HashBuilder module HashBuilder
def obj2hash(list)
self.class.models2hash list
end
def self.models2hash(list) def self.models2hash(list)
hash = [] if list.is_a? Array
list.each do |m| hash = []
hash << m.to_h list.each do |m|
end hash << m.to_h
end
hash hash
end
end end
end end
......
...@@ -62,6 +62,9 @@ module Dspace ...@@ -62,6 +62,9 @@ module Dspace
def connection_options def connection_options
{ {
url: @dspace_api || DSPACE_API, url: @dspace_api || DSPACE_API,
ssl: {
verify: false
},
headers: { headers: {
content_type: 'application/json', content_type: 'application/json',
'rest-dspace-token' => access_token.to_s, 'rest-dspace-token' => access_token.to_s,
......
module Dspace module Dspace
class Collection class Collection
include Dspace::Builders::HashBuilder
attr_accessor :name, :logo, :license, :copyright_text, attr_accessor :name, :logo, :license, :copyright_text,
:introductory_text, :short_description, :sidebar_text :introductory_text, :short_description, :sidebar_text
...@@ -49,11 +50,5 @@ module Dspace ...@@ -49,11 +50,5 @@ module Dspace
} }
end end
private
def obj2hash(list)
Dspace::Builders::HashBuilder.models2hash list
end
end end
end end
\ No newline at end of file
...@@ -20,8 +20,8 @@ module Dspace ...@@ -20,8 +20,8 @@ module Dspace
@short_description = args['shortDescription'] @short_description = args['shortDescription']
@sidebar_text = args['sidebarText'] @sidebar_text = args['sidebarText']
@count_items = args['countItems'] @count_items = args['countItems']
@sub_communities = Dspace::Builders::ModelBuilder.build_communities(args['subcommunities']) @sub_communities = Dspace::Builders::ModelBuilder.build_communities(args['subcommunities']) unless args['subcommunities'].nil?
@collections = Dspace::Builders::ModelBuilder.build_collections(args['collections']) @collections = Dspace::Builders::ModelBuilder.build_collections(args['collections']) unless args['collections'].nil?
@expand = args['expand'] @expand = args['expand']
end end
...@@ -48,7 +48,7 @@ module Dspace ...@@ -48,7 +48,7 @@ module Dspace
private private
def obj2hash(list) def obj2hash(list)
Dspace::Builders::HashBuilder.models2hash list Dspace::Builders::HashBuilder.models2hash list if list.is_a? Array
end end
end end
......
module Dspace module Dspace
class Item class Item
include Dspace::Builders::HashBuilder
attr_accessor :name, :archived, :withdrawn attr_accessor :name, :archived, :withdrawn
...@@ -57,11 +58,5 @@ module Dspace ...@@ -57,11 +58,5 @@ module Dspace
@metadata = [] @metadata = []
end end
private
def obj2hash(list)
Dspace::Builders::HashBuilder.models2hash list
end
end end
end end
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment