Class: Rafflesia::RelationPreviewData

Inherits:
Types::BaseModel
  • Object
show all
Defined in:
lib/rafflesia/cache/relation_preview_data.rb

Constant Summary collapse

HASH_ATTRS =
{
  columns: :columns,
  content_hash: :content_hash,
  database: :database,
  engine: :engine,
  limit: :limit,
  order_by: :order_by,
  relation: :relation,
  release: :release,
  returned_row_count: :returned_row_count,
  row_count: :row_count,
  rows: :rows,
  schema_columns: :schema_columns,
  schema_ref: :schema_ref
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ RelationPreviewData

Returns a new instance of RelationPreviewData.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rafflesia/cache/relation_preview_data.rb', line 39

def initialize(json)
  super()
  hash = self.class.normalize(json)
  @columns = (hash[:columns] || [])
  @content_hash = hash[:content_hash]
  @database = hash[:database]
  @engine = hash[:engine]
  @limit = hash[:limit]
  @order_by = (hash[:order_by] || [])
  @relation = hash[:relation]
  @release = hash[:release]
  @returned_row_count = hash[:returned_row_count]
  @row_count = hash[:row_count]
  @rows = (hash[:rows] || []).map { |item| item || {} }
  @schema_columns = (hash[:schema_columns] || []).map { |item| item ? Rafflesia::TableColumn.new(item) : nil }
  @schema_ref = hash[:schema_ref]
end

Instance Attribute Details

#columnsObject

Returns the value of attribute columns.



24
25
26
# File 'lib/rafflesia/cache/relation_preview_data.rb', line 24

def columns
  @columns
end

#content_hashObject

Returns the value of attribute content_hash.



24
25
26
# File 'lib/rafflesia/cache/relation_preview_data.rb', line 24

def content_hash
  @content_hash
end

#databaseObject

Returns the value of attribute database.



24
25
26
# File 'lib/rafflesia/cache/relation_preview_data.rb', line 24

def database
  @database
end

#engineObject

Returns the value of attribute engine.



24
25
26
# File 'lib/rafflesia/cache/relation_preview_data.rb', line 24

def engine
  @engine
end

#limitObject

Returns the value of attribute limit.



24
25
26
# File 'lib/rafflesia/cache/relation_preview_data.rb', line 24

def limit
  @limit
end

#order_byObject

Returns the value of attribute order_by.



24
25
26
# File 'lib/rafflesia/cache/relation_preview_data.rb', line 24

def order_by
  @order_by
end

#relationObject

Returns the value of attribute relation.



24
25
26
# File 'lib/rafflesia/cache/relation_preview_data.rb', line 24

def relation
  @relation
end

#releaseObject

Returns the value of attribute release.



24
25
26
# File 'lib/rafflesia/cache/relation_preview_data.rb', line 24

def release
  @release
end

#returned_row_countObject

Returns the value of attribute returned_row_count.



24
25
26
# File 'lib/rafflesia/cache/relation_preview_data.rb', line 24

def returned_row_count
  @returned_row_count
end

#row_countObject

Returns the value of attribute row_count.



24
25
26
# File 'lib/rafflesia/cache/relation_preview_data.rb', line 24

def row_count
  @row_count
end

#rowsObject

Returns the value of attribute rows.



24
25
26
# File 'lib/rafflesia/cache/relation_preview_data.rb', line 24

def rows
  @rows
end

#schema_columnsObject

Returns the value of attribute schema_columns.



24
25
26
# File 'lib/rafflesia/cache/relation_preview_data.rb', line 24

def schema_columns
  @schema_columns
end

#schema_refObject

Returns the value of attribute schema_ref.



24
25
26
# File 'lib/rafflesia/cache/relation_preview_data.rb', line 24

def schema_ref
  @schema_ref
end