Class: Prequel::CompositeTuple
- Inherits:
-
Object
- Object
- Prequel::CompositeTuple
- Defined in:
- lib/prequel/composite_tuple.rb
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #field_values ⇒ Object
- #get_field_value(name) ⇒ Object
- #get_record(table_name) ⇒ Object
-
#initialize(left, right) ⇒ CompositeTuple
constructor
A new instance of CompositeTuple.
Constructor Details
#initialize(left, right) ⇒ CompositeTuple
Returns a new instance of CompositeTuple.
5 6 7 |
# File 'lib/prequel/composite_tuple.rb', line 5 def initialize(left, right) @left, @right = left, right end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
3 4 5 |
# File 'lib/prequel/composite_tuple.rb', line 3 def left @left end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
3 4 5 |
# File 'lib/prequel/composite_tuple.rb', line 3 def right @right end |
Instance Method Details
#[](name) ⇒ Object
9 10 11 |
# File 'lib/prequel/composite_tuple.rb', line 9 def [](name) get_record(name) || get_field_value(name) end |
#field_values ⇒ Object
27 28 29 |
# File 'lib/prequel/composite_tuple.rb', line 27 def field_values [left.field_values, right.field_values] end |
#get_field_value(name) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/prequel/composite_tuple.rb', line 17 def get_field_value(name) if name =~ /(.+)__(.+)/ table_name = $1.to_sym field_name = $2.to_sym get_record(table_name).try(:get_field_value, field_name) else left.get_field_value(name) || right.get_field_value(name) end end |
#get_record(table_name) ⇒ Object
13 14 15 |
# File 'lib/prequel/composite_tuple.rb', line 13 def get_record(table_name) left.get_record(table_name) || right.get_record(table_name) end |