Class: Dina::BaseModel
- Inherits:
-
JsonApiClient::Resource
- Object
- JsonApiClient::Resource
- Dina::BaseModel
show all
- Includes:
- JsonApiClient::Helpers::Callbacks
- Defined in:
- lib/dina/models/base_model.rb
Direct Known Subclasses
AcquisitionEvent, Assemblage, Attachment, CollectingEvent, CollectingMethod, Collection, CollectionSequenceGenerator, Derivative, Identifier, IndexSet, Institution, ManagedAttribute, MaterialSample, MolecularSample, NgsWorkflow, ObjectStore, ObjectStoreManagedAttribute, ObjectSubtype, Organism, Organization, PcrBatch, PcrPrimer, Person, PreparationMethod, PreparationType, Product, Project, Protocol, Region, StorageUnit, StorageUnitType, ThermocyclerProfile, Transaction, User
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(params = {}) ⇒ BaseModel
Returns a new instance of BaseModel.
30
31
32
33
34
|
# File 'lib/dina/models/base_model.rb', line 30
def initialize(params = {})
symbolized_params = params.transform_keys(&:to_sym)
params["id"] = SecureRandom.uuid if !symbolized_params[:id]
super
end
|
Class Method Details
18
19
20
|
# File 'lib/dina/models/base_model.rb', line 18
def self.
{ content_type: "application/vnd.api+json", authorization: Dina::Authentication. }
end
|
.endpoint_path ⇒ Object
11
12
|
# File 'lib/dina/models/base_model.rb', line 11
def self.endpoint_path
end
|
.find_by_group(group, page: 1, per: 50) ⇒ Object
22
23
24
|
# File 'lib/dina/models/base_model.rb', line 22
def self.find_by_group(group, page: 1, per: 50)
self.where("group.groupName": group).page(page).per(per)
end
|
.properties ⇒ Object
26
27
28
|
# File 'lib/dina/models/base_model.rb', line 26
def self.properties
self.schema.instance_values["properties"]
end
|
Instance Method Details
#english_description ⇒ Object
36
37
38
39
40
|
# File 'lib/dina/models/base_model.rb', line 36
def english_description
if self.respond_to?(:multilingualDescription)
multilingualDescription[:descriptions].select{|o| o[:lang] == "en"}.first[:desc]
end
end
|
#french_description ⇒ Object
42
43
44
45
46
|
# File 'lib/dina/models/base_model.rb', line 42
def french_description
if self.respond_to?(:multilingualDescription)
multilingualDescription[:descriptions].select{|o| o[:lang] == "fr"}.first[:desc]
end
end
|