module BigRecord::FamilySpanColumns
Public Instance Methods
attributes_from_column_definition_with_family_span_columns()
click to toggle source
Initializes the attributes array with keys matching the columns from the linked table and the values matching the corresponding default value of that column, so that a new instance, or one populated from a passed-in Hash, still has all the attributes that instances loaded from the database would.
# File lib/big_record/family_span_columns.rb, line 79 def attributes_from_column_definition_with_family_span_columns self.simple_columns.inject({}) do |attributes, column| unless column.name == self.class.primary_key or column.family? attributes[column.name] = column.default end attributes end end
column_for_attribute_with_family_span_columns(name)
click to toggle source
Returns the column object for the named attribute.
# File lib/big_record/family_span_columns.rb, line 61 def column_for_attribute_with_family_span_columns(name) name = name.to_s # ignore methods '=' and '?' (e.g. 'normalized_srf_ief:231=') return if name =~ /=|\?$/ column = column_for_attribute_without_family_span_columns(name) unless column family = BigRecord::ConnectionAdapters::Column.extract_family(name) column = self.columns_hash[family] if family end column end
simple_columns()
click to toggle source
Returns the list of columns that are not spanned on a whole family
# File lib/big_record/family_span_columns.rb, line 56 def simple_columns columns.select{|c|!c.family?} end