Cross Reference: ontology_version.rb
xref
: /
ontohub
/
app
/
models
/
ontology_version.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
ontology_version.rb revision b9f99a06294e593ce8fb34b015e83003229db058
2867
N/A
class
OntologyVersion
<
ActiveRecord
::
Base
2867
N/A
include
OntologyVersion
::
Async
2867
N/A
include
OntologyVersion
::
Download
2867
N/A
include
OntologyVersion
::
Parsing
2867
N/A
2867
N/A
belongs_to
:
user
2867
N/A
belongs_to
:
ontology
, :
counter_cache
=> :
versions_count
2867
N/A
2867
N/A
mount_uploader
:
raw_file
,
OntologyUploader
2867
N/A
mount_uploader
:
xml_file
,
OntologyUploader
2867
N/A
2867
N/A
attr_accessible
:
raw_file
, :
source_uri
2867
N/A
2867
N/A
validate
:
raw_file_xor_source_uri
, :
on
=> :
create
2867
N/A
# validate :raw_file_size_maximum
2867
N/A
2867
N/A
validates_format_of
:
source_uri
,
2867
N/A
:
with
=>
URI
::
regexp
(
ALLOWED_URI_SCHEMAS
)
, :
if
=> :
source_uri
?
2867
N/A
2867
N/A
scope
:
latest
,
order
(
'id DESC'
)
2867
N/A
scope
:
state
, ->
(
state
)
{
where
:
state
=>
state
}
3017
N/A
scope
:
done
,
state
(
'done'
)
2867
N/A
2867
N/A
protected
2867
N/A
2867
N/A
def
raw_file_xor_source_uri
2867
N/A
if
!
(
raw_file.blank
? ^
source_uri.blank
?)
2867
N/A
errors.add
:
source_uri
,
'Specify either a source file or URI.'
2867
N/A
end
2867
N/A
end
2867
N/A
2867
N/A
def
raw_file_size_maximum
2867
N/A
if
raw_file.size
>
10.megabytes.to
_i
2867
N/A
errors.add
:
raw_file
,
'The maximum file size is 10M.'
2867
N/A
end
2867
N/A
end
2867
N/A
end
2867
N/A