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)

Instance Attribute Details

- (Hstore) metadata

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

- (Json) metadata_json

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

- (String) name

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

- (Object) get(key)



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

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

- (Object) set(key, value)



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