Method: Flydata::TableAttribute.extract_attribute

Defined in:
lib/flydata/table_attribute.rb

.extract_attribute(table_attributes, key) ⇒ Object

Extract => <value_for_a_given_key> pairs from table attributes arguments:

  • table_attributes (hash):

    { "<table-name1>" => {
        "invalid_table_reason" => "<error reason>",
        "pk_override" => ['id1', ...],
        "uk_as_pk" => ['uid', ...],...
      }, 
      "<table-name2> => {...},
    }
    
  • key (symbol or String): hash key in table_attributes

return value (hash):

{ "table_1" => <value_1>, "table_2" => <value_2>,...}


34
35
36
37
38
39
40
41
42
43
# File 'lib/flydata/table_attribute.rb', line 34

def self.extract_attribute(table_attributes, key)
  tbl_value_hash = {}
  table_attributes.each do |tbl_attr|

    table_name = tbl_attr['table_name']
    next unless tbl_attr.has_key?(key.to_s)
    tbl_value_hash[table_name] = tbl_attr[key.to_s]
  end
  tbl_value_hash
end