ontology.rb revision a4707bb77f9894e31b9e5b924c34e0095681cfe3
# Ontohub Library Includes
# Ontology Model Includes
# Multiple Class Features
attr_accessible :iri, :name, :description, :logic_id, :category_ids, :documentation, :acronym, :file_extension, :projects
allow_blank: true,
delegate :permission?, to: :repository
strip_attributes :only => [:name, :iri]
scope :search, ->(query) { where "ontologies.iri #{connection.ilike_operator} :term OR name #{connection.ilike_operator} :term", :term => "%" << query << "%" }
scope :list, includes(:logic).order('ontologies.state asc, ontologies.entities_count desc')
def self.find_by_file(file)
s_find_by_file(file).first
end
def to_s
name? ? name : iri
end
# title for links
def title
name? ? iri : nil
end
def symbols
entities
end
def symbols_count
entities_count
end
def path
"#{basepath}#{file_extension}"
end
def is?(logic_name)
self.logic ? (self.logic.name == logic_name) : false
end
protected
scope :s_find_by_file, ->(file) { where("ontologies.basepath = :basepath AND ontologies.file_extension = :file_extension AND parent_id IS NULL", basepath: File.basepath(file), file_extension: File.extname(file)) }
end