Class: Formio::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/formio/record.rb

Direct Known Subclasses

Nil

Defined Under Namespace

Classes: Nil

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(formio_hash) ⇒ Record

Returns a new instance of Record.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/formio/record.rb', line 3

def initialize(formio_hash)
  if formio_hash.empty? || formio_hash.nil?
    raise "cannot construct FormioRecord"
  end
  @_id = @id = formio_hash['_id']
  @form_id = formio_hash['form'] if formio_hash['form']
  @formio_hash = formio_hash
  @form_name = formio_hash['form_name']
  if formio_hash['created']
    @created_at = Time.parse formio_hash['created']
  end
  if formio_hash['modified']
    @updated_at = Time.parse formio_hash['modified']
  end
end

Instance Attribute Details

#_idObject (readonly)

Returns the value of attribute _id.



39
40
41
# File 'lib/formio/record.rb', line 39

def _id
  @_id
end

#created_atObject (readonly)

Returns the value of attribute created_at.



39
40
41
# File 'lib/formio/record.rb', line 39

def created_at
  @created_at
end

#form_idObject (readonly)

Returns the value of attribute form_id.



39
40
41
# File 'lib/formio/record.rb', line 39

def form_id
  @form_id
end

#form_nameObject (readonly)

Returns the value of attribute form_name.



39
40
41
# File 'lib/formio/record.rb', line 39

def form_name
  @form_name
end

#formio_hashObject (readonly)

Returns the value of attribute formio_hash.



39
40
41
# File 'lib/formio/record.rb', line 39

def formio_hash
  @formio_hash
end

#idObject (readonly)

Returns the value of attribute id.



39
40
41
# File 'lib/formio/record.rb', line 39

def id
  @id
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



39
40
41
# File 'lib/formio/record.rb', line 39

def updated_at
  @updated_at
end

Instance Method Details

#[](key) ⇒ Object



31
32
33
# File 'lib/formio/record.rb', line 31

def [](key)
  formio_hash[key]
end

#[]=(key, value) ⇒ Object



35
36
37
# File 'lib/formio/record.rb', line 35

def []=(key, value)
  formio_hash[key] = value
end

#present?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/formio/record.rb', line 19

def present?
  true
end

#to_hObject



27
28
29
# File 'lib/formio/record.rb', line 27

def to_h
  formio_hash
end

#to_jsonObject



23
24
25
# File 'lib/formio/record.rb', line 23

def to_json
  formio_hash.to_json
end