Module | Sequel::Plugins::ColumnConflicts::ClassMethods |
In: |
lib/sequel/plugins/column_conflicts.rb
|
get_column_conflicts | [R] | Hash for columns where the getter method already exists. keys are column symbols/strings that conflict with method names and should be looked up directly instead of calling a method, values are the column symbol to lookup in the values hash. |
set_column_conflicts | [R] | Hash for columns where the setter method already exists. keys are column symbols/strings suffixed with = that conflict with method names and should be set directly in the values hash, values are the column symbol to set in the values hash. |
Compare the column names for the model with the methods defined on Sequel::Model, and automatically setup the column conflicts.
# File lib/sequel/plugins/column_conflicts.rb, line 57 57: def check_column_conflicts 58: mod = Sequel::Model 59: columns.find_all{|c| mod.method_defined?(c)}.each{|c| get_column_conflict!(c)} 60: columns.find_all{|c| mod.method_defined?("#{c}=")}.each{|c| set_column_conflict!(c)} 61: end
Set the given column as one with a getter method conflict.
# File lib/sequel/plugins/column_conflicts.rb, line 64 64: def get_column_conflict!(column) 65: @get_column_conflicts[column.to_sym] = @get_column_conflicts[column.to_s] = column.to_sym 66: end