Class: Accessionable::Policy
- Defined in:
- app/models/accessionable/policy.rb
Overview
Represents policy information about who will have access to information associatied with manages (EGA) studies Comprised of a DAC and a URL. Should ideally be a completely separate record from Study but currently just a group of attributes in the Study::Metadata
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
- 
  
    
      #dac_accession_number  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute dac_accession_number. 
- 
  
    
      #policy_url  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute policy_url. 
- 
  
    
      #title  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute title. 
Attributes inherited from Base
#accession_number, #date, #date_short, #name
Instance Method Summary collapse
- #accessionable_id ⇒ Object
- #errors ⇒ Object
- 
  
    
      #initialize(study)  ⇒ Policy 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Policy. 
- #protect?(service) ⇒ Boolean
- #update_accession_number!(user, accession_number) ⇒ Object
- #xml ⇒ Object
Methods inherited from Base
#add_updated_event, #alias, #center_name, #extract_accession_number, #extract_array_express_accession_number, #file_name, #label_scope, #released?, #schema_type, #update_array_express_accession_number!
Constructor Details
#initialize(study) ⇒ Policy
Returns a new instance of Policy.
| 10 11 12 13 14 15 16 17 18 19 20 | # File 'app/models/accessionable/policy.rb', line 10 def initialize(study) @study = study @name = "Policy for study - #{study.name} - ##{study.id}" @policy_url = study..dac_policy @title = study..dac_policy_title # @dac_refname = study.dac_refname @dac_accession_number = study.dac_accession_number super(study.policy_accession_number) end | 
Instance Attribute Details
#dac_accession_number ⇒ Object (readonly)
Returns the value of attribute dac_accession_number.
| 8 9 10 | # File 'app/models/accessionable/policy.rb', line 8 def dac_accession_number @dac_accession_number end | 
#policy_url ⇒ Object (readonly)
Returns the value of attribute policy_url.
| 8 9 10 | # File 'app/models/accessionable/policy.rb', line 8 def policy_url @policy_url end | 
#title ⇒ Object (readonly)
Returns the value of attribute title.
| 8 9 10 | # File 'app/models/accessionable/policy.rb', line 8 def title @title end | 
Instance Method Details
#accessionable_id ⇒ Object
| 54 55 56 | # File 'app/models/accessionable/policy.rb', line 54 def accessionable_id @study.id end | 
#errors ⇒ Object
| 22 23 24 25 26 27 28 | # File 'app/models/accessionable/policy.rb', line 22 def errors [].tap do |errors| unless @dac_accession_number errors << 'DAC Accession number not found. Please get an accession number for the DAC.' end end end | 
#protect?(service) ⇒ Boolean
| 50 51 52 | # File 'app/models/accessionable/policy.rb', line 50 def protect?(service) service.policy_visibility(@study) == AccessionService::PROTECT end | 
#update_accession_number!(user, accession_number) ⇒ Object
| 43 44 45 46 47 48 | # File 'app/models/accessionable/policy.rb', line 43 def update_accession_number!(user, accession_number) @accession_number = accession_number add_updated_event(user, "Policy for Study #{@study.id}", @study) if @accession_number @study..ega_policy_accession_number = accession_number @study.save! end | 
#xml ⇒ Object
| 30 31 32 33 34 35 36 37 38 39 40 41 | # File 'app/models/accessionable/policy.rb', line 30 def xml xml = Builder::XmlMarkup.new xml.instruct! xml.POLICY_SET('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance') do xml.POLICY(alias: self.alias, accession: accession_number, center_name: center_name) do xml.TITLE title xml.DAC_REF(accession: dac_accession_number) xml.POLICY_FILE policy_url end end xml.target! end |