Class: Arel::Header
- Inherits:
-
Object
- Object
- Arel::Header
- Includes:
- Enumerable
- Defined in:
- lib/arel/algebra/header.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](key) ⇒ Object
- #bind(relation) ⇒ Object
- #each ⇒ Object
-
#index(i) ⇒ Object
TMP.
-
#initialize(attrs = []) ⇒ Header
constructor
A new instance of Header.
- #to_ary ⇒ Object
- #union(other) ⇒ Object (also: #|)
Constructor Details
#initialize(attrs = []) ⇒ Header
Returns a new instance of Header.
5 6 7 8 |
# File 'lib/arel/algebra/header.rb', line 5 def initialize(attrs = []) @attributes = attrs.to_ary @names = {} end |
Instance Method Details
#==(other) ⇒ Object
22 23 24 |
# File 'lib/arel/algebra/header.rb', line 22 def ==(other) to_set == other.to_set end |
#[](key) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/arel/algebra/header.rb', line 15 def [](key) case key when String, Symbol then find_by_name(key) when Attribute then find_by_attribute(key) end end |
#bind(relation) ⇒ Object
36 37 38 |
# File 'lib/arel/algebra/header.rb', line 36 def bind(relation) Header.new(map { |a| a.bind(relation) }) end |
#each ⇒ Object
10 11 12 13 |
# File 'lib/arel/algebra/header.rb', line 10 def each to_ary.each { |e| yield e } self end |
#index(i) ⇒ Object
TMP
41 42 43 |
# File 'lib/arel/algebra/header.rb', line 41 def index(i) to_ary.index(i) end |
#to_ary ⇒ Object
32 33 34 |
# File 'lib/arel/algebra/header.rb', line 32 def to_ary @attributes end |
#union(other) ⇒ Object Also known as: |
26 27 28 |
# File 'lib/arel/algebra/header.rb', line 26 def union(other) new(to_ary | other) end |