Skip to content

Commit efb330f

Browse files
Code clean and refactor ( to use newer hash syntax )
1 parent eb9efc3 commit efb330f

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

lib/ontologies_linked_data/models/instance.rb

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ module Models
44
class Instance < LinkedData::Models::Base
55

66
model :named_individual, name_with: :id, collection: :submission,
7-
namespace: :owl, :schemaless => :true , rdf_type: lambda { |*x| RDF::OWL[:NamedIndividual]}
8-
7+
namespace: :owl, schemaless: :true , rdf_type: lambda { |*x| RDF::OWL[:NamedIndividual]}
98

109
attribute :label, namespace: :rdfs, enforce: [:list]
1110
attribute :prefLabel, namespace: :skos, enforce: [:existence], alias: true
1211

13-
attribute :types, :namespace => :rdf, enforce: [:list], property: :type
14-
attribute :submission, :collection => lambda { |s| s.resource_id }, :namespace => :metadata
12+
attribute :types, namespace: :rdf, enforce: [:list], property: :type
13+
attribute :submission, collection: lambda { |s| s.resource_id }, namespace: :metadata
1514

1615
serialize_never :submission, :id
1716
serialize_methods :properties
@@ -38,19 +37,18 @@ def self.get_instances_by_class(submission_id,class_id, page_no=1, size=50)
3837

3938
inst = self.instances_by_class_where_query(s,class_id).page(page_no,size).all
4039

41-
if inst.length > 0 # TODO test if "include=all" parameter is passed in the request
42-
self.load_unmapped s,inst # For getting all the properties # For getting all the properties
43-
end
44-
end
40+
# TODO test if "include=all" parameter is passed in the request
41+
load_unmapped s,inst unless if inst.empty? # For getting all the properties # For getting all the properties
4542

43+
end
4644

4745
def self.get_instances_by_ontology(submission_id,page_no=1,size=50)
4846
## TODO: pass directly an LinkedData::Models::OntologySubmission instance in the arguments instead of submission_id
4947
s = LinkedData::Models::OntologySubmission.find(submission_id).first
5048
inst = s.nil? ? [] : self.instances_by_class_where_query(s).page(page_no,size).all
5149

52-
if inst.length > 0 ## TODO test if "include=all" parameter is passed in the request
53-
self.load_unmapped s,inst # For getting all the properties
50+
## TODO test if "include=all" parameter is passed in the request
51+
load_unmapped s,inst unless inst.empty? # For getting all the properties
5452
end
5553
end
5654

0 commit comments

Comments
 (0)