Module: Sequel::Plugins::ColumnConflicts::ClassMethods
- Defined in:
- lib/sequel/plugins/column_conflicts.rb
Instance Attribute Summary collapse
- 
  
    
      #get_column_conflicts  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Hash for columns where the getter method already exists. 
- 
  
    
      #set_column_conflicts  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Hash for columns where the setter method already exists. 
Instance Method Summary collapse
- 
  
    
      #check_column_conflicts  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Compare the column names for the model with the methods defined on Sequel::Model, and automatically setup the column conflicts. 
- 
  
    
      #freeze  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Freeze column conflict information when freezing model class. 
- 
  
    
      #get_column_conflict!(column)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Set the given column as one with a getter method conflict. 
- 
  
    
      #set_column_conflict!(column)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Set the given column as one with a setter method conflict. 
Instance Attribute Details
#get_column_conflicts ⇒ Object (readonly)
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.
| 53 54 55 | # File 'lib/sequel/plugins/column_conflicts.rb', line 53 def get_column_conflicts @get_column_conflicts end | 
#set_column_conflicts ⇒ Object (readonly)
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.
| 58 59 60 | # File 'lib/sequel/plugins/column_conflicts.rb', line 58 def set_column_conflicts @set_column_conflicts end | 
Instance Method Details
#check_column_conflicts ⇒ Object
Compare the column names for the model with the methods defined on Sequel::Model, and automatically setup the column conflicts.
| 62 63 64 65 66 | # File 'lib/sequel/plugins/column_conflicts.rb', line 62 def check_column_conflicts mod = Sequel::Model columns.find_all{|c| mod.method_defined?(c)}.each{|c| get_column_conflict!(c)} columns.find_all{|c| mod.method_defined?("#{c}=")}.each{|c| set_column_conflict!(c)} end | 
#freeze ⇒ Object
Freeze column conflict information when freezing model class.
| 69 70 71 72 73 74 | # File 'lib/sequel/plugins/column_conflicts.rb', line 69 def freeze @get_column_conflicts.freeze @set_column_conflicts.freeze super end | 
#get_column_conflict!(column) ⇒ Object
Set the given column as one with a getter method conflict.
| 77 78 79 | # File 'lib/sequel/plugins/column_conflicts.rb', line 77 def get_column_conflict!(column) @get_column_conflicts[column.to_sym] = @get_column_conflicts[column.to_s] = column.to_sym end | 
#set_column_conflict!(column) ⇒ Object
Set the given column as one with a setter method conflict.
| 82 83 84 | # File 'lib/sequel/plugins/column_conflicts.rb', line 82 def set_column_conflict!(column) @set_column_conflicts[:"#{column}="] = @set_column_conflicts["#{column}="] = column.to_sym end |