Class: Arel::Array

Inherits:
Object
  • Object
show all
Includes:
Recursion::BaseCase, Relation
Defined in:
lib/arel/engines/memory/relations/array.rb

Instance Attribute Summary

Attributes included from Relation

#count

Instance Method Summary collapse

Methods included from Recursion::BaseCase

#table, #table_sql

Methods included from Relation

#bind, #call, #christener, #compiler, #exclusion_predicate_sql, #externalizable?, #externalize, #inclusion_predicate_sql, #join?, #primary_key, #session, #to_sql

Methods included from Relation::DefaultOperations

#groupings, #havings, #inserts, #joins, #locked, #orders, #projections, #skipped, #sources, #taken, #wheres

Methods included from Relation::AttributeAccessable

#[], #find_attribute_matching_attribute, #find_attribute_matching_name, #position_of

Methods included from Relation::Operable

#alias, #join, #lock, #outer_join

Methods included from Relation::Operable::Writable

#delete, #insert, #update

Methods included from Relation::Enumerable

#each, #first

Constructor Details

#initialize(array, attribute_names_and_types) ⇒ Array

Returns a new instance of Array.



9
10
11
# File 'lib/arel/engines/memory/relations/array.rb', line 9

def initialize(array, attribute_names_and_types)
  @array, @attribute_names_and_types = array, attribute_names_and_types
end

Instance Method Details

#attributesObject



17
18
19
20
21
22
23
24
25
# File 'lib/arel/engines/memory/relations/array.rb', line 17

def attributes
  @attributes ||= begin
    attrs = @attribute_names_and_types.collect do |attribute, type|
      attribute = type.new(self, attribute) if Symbol === attribute
      attribute
    end
    Header.new(attrs)
  end
end

#engineObject



13
14
15
# File 'lib/arel/engines/memory/relations/array.rb', line 13

def engine
  @engine ||= Memory::Engine.new
end

#evalObject



31
32
33
# File 'lib/arel/engines/memory/relations/array.rb', line 31

def eval
  @array.collect { |r| Row.new(self, r) }
end

#format(attribute, value) ⇒ Object



27
28
29
# File 'lib/arel/engines/memory/relations/array.rb', line 27

def format(attribute, value)
  value
end