module Sequel::Plugins::ColumnConflicts::ClassMethods

  1. lib/sequel/plugins/column_conflicts.rb

Attributes

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.

Public Instance methods

check_column_conflicts()

Compare the column names for the model with the methods defined on Sequel::Model, and automatically setup the column conflicts.

[show source]
   # File lib/sequel/plugins/column_conflicts.rb
62 def check_column_conflicts
63   mod = Sequel::Model
64   columns.find_all{|c| mod.method_defined?(c)}.each{|c| get_column_conflict!(c)}
65   columns.find_all{|c| mod.method_defined?("#{c}=")}.each{|c| set_column_conflict!(c)}
66 end
freeze()

Freeze column conflict information when freezing model class.

[show source]
   # File lib/sequel/plugins/column_conflicts.rb
69 def freeze
70   @get_column_conflicts.freeze
71   @set_column_conflicts.freeze
72 
73   super
74 end
get_column_conflict!(column)

Set the given column as one with a getter method conflict.

[show source]
   # File lib/sequel/plugins/column_conflicts.rb
77 def get_column_conflict!(column)
78   @get_column_conflicts[column.to_sym] = @get_column_conflicts[column.to_s] = column.to_sym
79 end
set_column_conflict!(column)

Set the given column as one with a setter method conflict.

[show source]
   # File lib/sequel/plugins/column_conflicts.rb
82 def set_column_conflict!(column)
83   @set_column_conflicts[:"#{column}="] = @set_column_conflicts["#{column}="] = column.to_sym
84 end