Class: Retab::SchemaGeneration

Inherits:
Types::BaseModel show all
Defined in:
lib/retab/schemas/schema_generation.rb

Constant Summary collapse

HASH_ATTRS =
{
  object: :object,
  created_at: :created_at,
  json_schema: :json_schema,
  strict: :strict,
  id: :id,
  status: :status,
  error: :error
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Types::BaseModel

#last_response

Instance Method Summary collapse

Methods inherited from Types::BaseModel

deep_symbolize, #inspect, normalize, #to_h, #to_json

Constructor Details

#initialize(json) ⇒ SchemaGeneration

Returns a new instance of SchemaGeneration.



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/retab/schemas/schema_generation.rb', line 28

def initialize(json)
  super()
  hash = self.class.normalize(json)
  @object = hash[:object].nil? ? "schema" : hash[:object]
  @created_at = hash[:created_at]
  @json_schema = hash[:json_schema] || {}
  @strict = hash[:strict].nil? ? true : hash[:strict]
  @id = hash[:id]
  @status = hash[:status].nil? ? "pending" : hash[:status]
  @error = hash[:error] ? Retab::PrimitiveError.new(hash[:error]) : nil
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



18
19
20
# File 'lib/retab/schemas/schema_generation.rb', line 18

def created_at
  @created_at
end

#errorObject

Returns the value of attribute error.



18
19
20
# File 'lib/retab/schemas/schema_generation.rb', line 18

def error
  @error
end

#idObject

Returns the value of attribute id.



18
19
20
# File 'lib/retab/schemas/schema_generation.rb', line 18

def id
  @id
end

#json_schemaObject

Returns the value of attribute json_schema.



18
19
20
# File 'lib/retab/schemas/schema_generation.rb', line 18

def json_schema
  @json_schema
end

#objectObject

Returns the value of attribute object.



18
19
20
# File 'lib/retab/schemas/schema_generation.rb', line 18

def object
  @object
end

#statusObject

Returns the value of attribute status.



18
19
20
# File 'lib/retab/schemas/schema_generation.rb', line 18

def status
  @status
end

#strictObject

Returns the value of attribute strict.



18
19
20
# File 'lib/retab/schemas/schema_generation.rb', line 18

def strict
  @strict
end