Class: Template

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

Overview

This model manage the questions template

Validations

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#created_atDateTime

Returns when the record was created.

Returns:

  • (DateTime)

    when the record was created



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/template.rb', line 17

class Template < ApplicationRecord
  validates :title, presence: true

  # set data attribute from a JSON string
  def data_string=(value)
    self.data = JSON.try :parse, value
  end

  # @return {data} value as json string
  def data_string
    data.to_json
  end
end

#dataArray

Returns List of Question attributes.

Returns:

  • (Array)

    List of Question attributes



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/template.rb', line 17

class Template < ApplicationRecord
  validates :title, presence: true

  # set data attribute from a JSON string
  def data_string=(value)
    self.data = JSON.try :parse, value
  end

  # @return {data} value as json string
  def data_string
    data.to_json
  end
end

#idInteger

Returns unique identifier for Template.

Returns:

  • (Integer)

    unique identifier for Template



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/template.rb', line 17

class Template < ApplicationRecord
  validates :title, presence: true

  # set data attribute from a JSON string
  def data_string=(value)
    self.data = JSON.try :parse, value
  end

  # @return {data} value as json string
  def data_string
    data.to_json
  end
end

#titleString

Returns Template title.

Returns:



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/template.rb', line 17

class Template < ApplicationRecord
  validates :title, presence: true

  # set data attribute from a JSON string
  def data_string=(value)
    self.data = JSON.try :parse, value
  end

  # @return {data} value as json string
  def data_string
    data.to_json
  end
end

#updated_atDateTime

Returns when the record was updated.

Returns:

  • (DateTime)

    when the record was updated



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/template.rb', line 17

class Template < ApplicationRecord
  validates :title, presence: true

  # set data attribute from a JSON string
  def data_string=(value)
    self.data = JSON.try :parse, value
  end

  # @return {data} value as json string
  def data_string
    data.to_json
  end
end

Instance Method Details

#data_stringdata

Returns value as json string.

Returns:

  • (data)

    value as json string



26
27
28
# File 'app/models/template.rb', line 26

def data_string
  data.to_json
end

#data_string=(value) ⇒ Object

set data attribute from a JSON string



21
22
23
# File 'app/models/template.rb', line 21

def data_string=(value)
  self.data = JSON.try :parse, value
end