Class: Archon::Nodes::PopulatedRecordset

Inherits:
Arel::Nodes::NamedFunction
  • Object
show all
Defined in:
lib/archon/nodes/populated_recordset.rb

Overview

PopulatedRecordset

This ARel node creates a populated recordset from a JSON generated by the given ruby array of hashes.

Instance Method Summary collapse

Constructor Details

#initialize(base, rows = []) ⇒ PopulatedRecordset

Returns a new instance of PopulatedRecordset.

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
# File 'lib/archon/nodes/populated_recordset.rb', line 13

def initialize(base, rows = [])
  raise ArgumentError, "rows is not an array" unless rows.is_a? Array
  super 'json_populate_recordset', [
    Arel::Nodes::SqlLiteral.new(base),
    Arel::Nodes::Quoted.new(ActiveSupport::JSON.encode(rows))
  ]
end

Instance Method Details

#aliased_as(recordset_alias) ⇒ Object



21
22
23
# File 'lib/archon/nodes/populated_recordset.rb', line 21

def aliased_as(recordset_alias)
  Arel::Nodes::TableAlias.new(self, recordset_alias)
end

#selectableObject



25
26
27
# File 'lib/archon/nodes/populated_recordset.rb', line 25

def selectable
  Arel::SelectManager.new self
end