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.
26
27
28
29
30
|
# File 'lib/dina/models/base_model.rb', line 26
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
|
Instance Method Details
#english_description ⇒ Object
32
33
34
35
36
|
# File 'lib/dina/models/base_model.rb', line 32
def english_description
if self.respond_to?(:multilingualDescription)
multilingualDescription[:descriptions].select{|o| o[:lang] == "en"}.first[:desc]
end
end
|
#french_description ⇒ Object
38
39
40
41
42
|
# File 'lib/dina/models/base_model.rb', line 38
def french_description
if self.respond_to?(:multilingualDescription)
multilingualDescription[:descriptions].select{|o| o[:lang] == "fr"}.first[:desc]
end
end
|