Class: Fauxsql::AttributeList

Inherits:
Array
  • Object
show all
Defined in:
lib/fauxsql/attribute_list.rb

Overview

AttributeList is an Array that dereferences and resolves fauxsql attributes when setting/reading members in the Array

Direct Known Subclasses

AttributeManymany

Instance Method Summary collapse

Instance Method Details

#-(others) ⇒ Object



37
38
39
40
41
# File 'lib/fauxsql/attribute_list.rb', line 37

def -(others)
  others = others.map{|other| Fauxsql.dereference_fauxsql_attribute(other).hash }
  reject!{|one| others.include?(one.hash) }
  self
end

#<<(attribute) ⇒ Object



5
6
7
# File 'lib/fauxsql/attribute_list.rb', line 5

def <<(attribute)
  super Fauxsql.dereference_fauxsql_attribute(attribute)
end

#[](index) ⇒ Object



9
10
11
# File 'lib/fauxsql/attribute_list.rb', line 9

def [] index
  Fauxsql.resolve_fauxsql_attribute super(index)
end

#allObject



21
22
23
# File 'lib/fauxsql/attribute_list.rb', line 21

def all
  map{|item| Fauxsql.resolve_fauxsql_attribute item }
end

#eachObject



29
30
31
# File 'lib/fauxsql/attribute_list.rb', line 29

def each
  super{|item| yield(Fauxsql.resolve_fauxsql_attribute(item)) }
end

#each_with_indexObject



33
34
35
# File 'lib/fauxsql/attribute_list.rb', line 33

def each_with_index
  super{|item, index| yield(Fauxsql.resolve_fauxsql_attribute(item), index) }
end

#eql?(other) ⇒ Boolean

Always being not eql is expensive TODO make this work without this hack

Returns:

  • (Boolean)


45
46
47
# File 'lib/fauxsql/attribute_list.rb', line 45

def eql?(other)
  return false
end

#equals(list) ⇒ Object



25
26
27
# File 'lib/fauxsql/attribute_list.rb', line 25

def equals list
  map_resolved == list
end

#firstObject



13
14
15
# File 'lib/fauxsql/attribute_list.rb', line 13

def first
  self[0]
end

#lastObject



17
18
19
# File 'lib/fauxsql/attribute_list.rb', line 17

def last
  self[length - 1]
end