Class: Import

Inherits:
ApplicationRecord show all
Defined in:
app/models/import.rb

Overview

A class used for transient data, primarily in the development of import scripts.

Possible usage

i = Import.find_or_create_by_name('My Import')

# set some values

my_values = ['a', 'b', 'c']

i.set('my_values_name', my_values)

i.get('my_values_name') # =>  ['a', 'b', 'c']

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

transaction_with_retry

Instance Attribute Details

#metadataHstore

Returns a Hstore column.

Returns:

  • (Hstore)

    a Hstore column



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/models/import.rb', line 28

class Import < ApplicationRecord
  store_accessor :metadata

  validates_presence_of :name
  validates_uniqueness_of :name

  def set(key, value)
    h      = 
    h      ||= {}
    h[key] = value
    update_attribute(:metadata_json, h)
  end

  def get(key)
    return nil if .nil?
    [key]
  end

end

#metadata_jsonJson

Returns a JSON column.

Returns:

  • (Json)

    a JSON column



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/models/import.rb', line 28

class Import < ApplicationRecord
  store_accessor :metadata

  validates_presence_of :name
  validates_uniqueness_of :name

  def set(key, value)
    h      = 
    h      ||= {}
    h[key] = value
    update_attribute(:metadata_json, h)
  end

  def get(key)
    return nil if .nil?
    [key]
  end

end

#nameString

Returns required, the lookup name.

Returns:

  • (String)

    required, the lookup name



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/models/import.rb', line 28

class Import < ApplicationRecord
  store_accessor :metadata

  validates_presence_of :name
  validates_uniqueness_of :name

  def set(key, value)
    h      = 
    h      ||= {}
    h[key] = value
    update_attribute(:metadata_json, h)
  end

  def get(key)
    return nil if .nil?
    [key]
  end

end

Instance Method Details

#get(key) ⇒ Object



41
42
43
44
# File 'app/models/import.rb', line 41

def get(key)
  return nil if .nil?
  [key]
end

#set(key, value) ⇒ Object



34
35
36
37
38
39
# File 'app/models/import.rb', line 34

def set(key, value)
  h      = 
  h      ||= {}
  h[key] = value
  update_attribute(:metadata_json, h)
end