Class: DataGraph::CpkLinkage
- Defined in:
- lib/data_graph/cpk_linkage.rb
Instance Attribute Summary
Attributes inherited from Linkage
#child_columns, #child_node, #connection, #macro, #name, #parent_columns, #table_name, #through
Instance Method Summary collapse
Methods inherited from Linkage
#inherit, #inherit!, #initialize, #link, #node
Methods included from Utils
cpk?, foreign_key, patherize_attrs, primary_keys, reference_key
Constructor Details
This class inherits a constructor from DataGraph::Linkage
Instance Method Details
#child_id(record) ⇒ Object
9 10 11 |
# File 'lib/data_graph/cpk_linkage.rb', line 9 def child_id(record) child_columns.collect {|attribute| record.send(attribute) } end |
#conditions(id_map) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/data_graph/cpk_linkage.rb', line 13 def conditions(id_map) condition = child_columns.collect {|col| "#{table_name}.#{connection.quote_column_name(col)} = ?" }.join(' AND ') conditions = Array.new(id_map.length, condition) conditions_str = "(#{conditions.join(') OR (')})" id_map.keys.flatten.unshift(conditions_str) end |
#parent_id(record) ⇒ Object
5 6 7 |
# File 'lib/data_graph/cpk_linkage.rb', line 5 def parent_id(record) parent_columns.collect {|attribute| record.send(attribute) } end |