Sha256: f4d960346a3adb3a48a6720b3d3ecb761148d4d808db4886b3002c7d597a3b18
Contents?: true
Size: 1.46 KB
Versions: 26
Compression:
Stored size: 1.46 KB
Contents
# encoding: UTF-8 module Wice class TableColumnMatrix < Hash #:nodoc: attr_reader :generated_conditions def initialize() #:nodoc: super @generated_conditions = [] @by_table_names = HashWithIndifferentAccess.new end def add_condition(column, conditions) @generated_conditions << [column, conditions] unless conditions.blank? end def conditions @generated_conditions.collect{|_, cond| cond} end alias_method :get, :[] attr_reader :default_model_class def default_model_class=(model) #:nodoc: init_columns_of_table(model) unless has_key?(model) @default_model_class = model end def [](model) #:nodoc: init_columns_of_table(model) unless has_key?(model) get(model) end def get_column_by_model_class_and_column_name(model_class, column_name) #:nodoc: self[model_class][column_name] end def get_column_in_default_model_class_by_column_name(column_name) #:nodoc: raise WiceGridException.new("Cannot search for a column in a default model as the default model is not set") if @default_model_class.nil? self[@default_model_class][column_name] end def init_columns_of_table(model) #:nodoc: self[model] = HashWithIndifferentAccess.new(model.columns.index_by(&:name)) @by_table_names[model.table_name] = self[model] self[model].each_value{|c| c.model = model} end alias_method :<< , :init_columns_of_table end end
Version data entries
26 entries across 26 versions & 1 rubygems