Class: Formio::Form

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(formio_hash) ⇒ Form

Returns a new instance of Form.



15
16
17
18
19
20
21
22
23
24
# File 'lib/formio/form.rb', line 15

def initialize(formio_hash)
  @formio_hash = formio_hash
  @type = formio_hash['type']
  @formio_id = formio_hash['_id']
  @components = formio_hash['components']
  @name = @title = formio_hash['title']
  @path = formio_hash['path']
  @created_at = DateTime.parse formio_hash['created']
  @updated_at = DateTime.parse formio_hash['modified']
end

Instance Attribute Details

#componentsObject

Returns the value of attribute components.



3
4
5
# File 'lib/formio/form.rb', line 3

def components
  @components
end

#created_atObject

Returns the value of attribute created_at.



3
4
5
# File 'lib/formio/form.rb', line 3

def created_at
  @created_at
end

#formio_hashObject

Returns the value of attribute formio_hash.



3
4
5
# File 'lib/formio/form.rb', line 3

def formio_hash
  @formio_hash
end

#formio_idObject

Returns the value of attribute formio_id.



3
4
5
# File 'lib/formio/form.rb', line 3

def formio_id
  @formio_id
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/formio/form.rb', line 3

def name
  @name
end

#pathObject

Returns the value of attribute path.



3
4
5
# File 'lib/formio/form.rb', line 3

def path
  @path
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/formio/form.rb', line 3

def title
  @title
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/formio/form.rb', line 3

def type
  @type
end

#updated_atObject

Returns the value of attribute updated_at.



3
4
5
# File 'lib/formio/form.rb', line 3

def updated_at
  @updated_at
end

Instance Method Details

#to_jsonObject



34
35
36
37
38
39
40
41
42
43
# File 'lib/formio/form.rb', line 34

def to_json
  {
    title: title,
    display: 'form',
    type: type,
    name: name,
    path: path,
    components: components,
  }.to_json
end