Class: PreparationType

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Housekeeping::Timestamps, Housekeeping::Users, Shared::IsData, Shared::SharedAcrossProjects, Shared::Taggable
Defined in:
app/models/preparation_type.rb

Overview

A PreparationType describes how a collection object was prepared for preservation in a collection. At present we're building a shared controlled vocabulary that we may ultimately try and turn into an ontology.

Instance Attribute Summary (collapse)

Attributes included from Housekeeping::Users

#by

Class Method Summary (collapse)

Methods included from Housekeeping::Timestamps

#data_breakdown_for_chartkick_recent

Methods included from Housekeeping::Users

#set_created_by_id, #set_updated_by_id

Instance Attribute Details

- (String) definition

Returns a definition describing the preparation

Returns:

  • (String)

    a definition describing the preparation



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/preparation_type.rb', line 12

class PreparationType < ActiveRecord::Base
  include Housekeeping::Users
  include Housekeeping::Timestamps
  include Shared::IsData
  include Shared::Taggable
  include Shared::SharedAcrossProjects
 
  has_paper_trail

  has_many :collection_objects, dependent: :restrict_with_error
  validates_presence_of :name, :definition

  def self.generate_download(scope)
    CSV.generate do |csv|
      csv << column_names
      scope.order(id: :asc).find_each do |o|
        csv << o.attributes.values_at(*column_names).collect { |i|
          i.to_s.gsub(/\n/, '\n').gsub(/\t/, '\t')
        }
      end
    end
  end

end

- (String) name

Returns the name of the preparation

Returns:

  • (String)

    the name of the preparation



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/models/preparation_type.rb', line 12

class PreparationType < ActiveRecord::Base
  include Housekeeping::Users
  include Housekeeping::Timestamps
  include Shared::IsData
  include Shared::Taggable
  include Shared::SharedAcrossProjects
 
  has_paper_trail

  has_many :collection_objects, dependent: :restrict_with_error
  validates_presence_of :name, :definition

  def self.generate_download(scope)
    CSV.generate do |csv|
      csv << column_names
      scope.order(id: :asc).find_each do |o|
        csv << o.attributes.values_at(*column_names).collect { |i|
          i.to_s.gsub(/\n/, '\n').gsub(/\t/, '\t')
        }
      end
    end
  end

end

Class Method Details

+ (Object) generate_download(scope)



24
25
26
27
28
29
30
31
32
33
# File 'app/models/preparation_type.rb', line 24

def self.generate_download(scope)
  CSV.generate do |csv|
    csv << column_names
    scope.order(id: :asc).find_each do |o|
      csv << o.attributes.values_at(*column_names).collect { |i|
        i.to_s.gsub(/\n/, '\n').gsub(/\t/, '\t')
      }
    end
  end
end