Class: Retab::EditTemplate

Inherits:
Types::BaseModel show all
Defined in:
lib/retab/edit_templates/edit_template.rb

Constant Summary collapse

HASH_ATTRS =
{
  id: :id,
  name: :name,
  file: :file,
  form_fields: :form_fields,
  field_count: :field_count,
  created_at: :created_at,
  updated_at: :updated_at
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Types::BaseModel

#last_response

Instance Method Summary collapse

Methods inherited from Types::BaseModel

#inspect, normalize, #to_h, #to_json

Constructor Details

#initialize(json) ⇒ EditTemplate

Returns a new instance of EditTemplate.



27
28
29
30
31
32
33
34
35
36
# File 'lib/retab/edit_templates/edit_template.rb', line 27

def initialize(json)
  hash = self.class.normalize(json)
  @id = hash[:id]
  @name = hash[:name]
  @file = hash[:file] ? Retab::FileRef.new(hash[:file]) : nil
  @form_fields = (hash[:form_fields] || []).map { |item| item ? Retab::FormField.new(item) : nil }
  @field_count = hash[:field_count]
  @created_at = hash[:created_at]
  @updated_at = hash[:updated_at]
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



18
19
20
# File 'lib/retab/edit_templates/edit_template.rb', line 18

def created_at
  @created_at
end

#field_countObject

Returns the value of attribute field_count.



18
19
20
# File 'lib/retab/edit_templates/edit_template.rb', line 18

def field_count
  @field_count
end

#fileObject

Returns the value of attribute file.



18
19
20
# File 'lib/retab/edit_templates/edit_template.rb', line 18

def file
  @file
end

#form_fieldsObject

Returns the value of attribute form_fields.



18
19
20
# File 'lib/retab/edit_templates/edit_template.rb', line 18

def form_fields
  @form_fields
end

#idObject

Returns the value of attribute id.



18
19
20
# File 'lib/retab/edit_templates/edit_template.rb', line 18

def id
  @id
end

#nameObject

Returns the value of attribute name.



18
19
20
# File 'lib/retab/edit_templates/edit_template.rb', line 18

def name
  @name
end

#updated_atObject

Returns the value of attribute updated_at.



18
19
20
# File 'lib/retab/edit_templates/edit_template.rb', line 18

def updated_at
  @updated_at
end