Class: Formio::Record
- Inherits:
-
Object
- Object
- Formio::Record
- Defined in:
- lib/formio/record.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Nil
Instance Attribute Summary collapse
-
#_id ⇒ Object
readonly
Returns the value of attribute _id.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#form_id ⇒ Object
readonly
Returns the value of attribute form_id.
-
#form_name ⇒ Object
readonly
Returns the value of attribute form_name.
-
#formio_hash ⇒ Object
readonly
Returns the value of attribute formio_hash.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
-
#initialize(formio_hash) ⇒ Record
constructor
A new instance of Record.
- #present? ⇒ Boolean
- #to_h ⇒ Object
- #to_json ⇒ Object
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
#_id ⇒ Object (readonly)
Returns the value of attribute _id.
39 40 41 |
# File 'lib/formio/record.rb', line 39 def _id @_id end |
#created_at ⇒ Object (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_id ⇒ Object (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_name ⇒ Object (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_hash ⇒ Object (readonly)
Returns the value of attribute formio_hash.
39 40 41 |
# File 'lib/formio/record.rb', line 39 def formio_hash @formio_hash end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
39 40 41 |
# File 'lib/formio/record.rb', line 39 def id @id end |
#updated_at ⇒ Object (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
19 20 21 |
# File 'lib/formio/record.rb', line 19 def present? true end |
#to_h ⇒ Object
27 28 29 |
# File 'lib/formio/record.rb', line 27 def to_h formio_hash end |
#to_json ⇒ Object
23 24 25 |
# File 'lib/formio/record.rb', line 23 def to_json formio_hash.to_json end |