Module: Sequel::ConstantSqlOverride::DatabaseMethods
- Defined in:
- lib/sequel/extensions/constant_sql_override.rb
Instance Attribute Summary collapse
- 
  
    
      #constant_sqls  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Hash mapping constant symbols to SQL. 
Class Method Summary collapse
- 
  
    
      .extended(db)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Create the initial empty hash of constant sql overrides. 
Instance Method Summary collapse
- 
  
    
      #freeze  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Freeze the constant_sqls hash to prevent adding new overrides. 
- 
  
    
      #set_constant_sql(constant, override)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Set the SQL to use for the given Sequel::SQL::Constant. 
Instance Attribute Details
#constant_sqls ⇒ Object (readonly)
Hash mapping constant symbols to SQL. For internal use only.
| 38 39 40 | # File 'lib/sequel/extensions/constant_sql_override.rb', line 38 def constant_sqls @constant_sqls end | 
Class Method Details
.extended(db) ⇒ Object
Create the initial empty hash of constant sql overrides.
| 30 31 32 33 34 35 | # File 'lib/sequel/extensions/constant_sql_override.rb', line 30 def self.extended(db) db.instance_exec do @constant_sqls ||= {} extend_datasets(DatasetMethods) end end | 
Instance Method Details
#freeze ⇒ Object
Freeze the constant_sqls hash to prevent adding new overrides.
| 46 47 48 49 | # File 'lib/sequel/extensions/constant_sql_override.rb', line 46 def freeze @constant_sqls.freeze super end | 
#set_constant_sql(constant, override) ⇒ Object
Set the SQL to use for the given Sequel::SQL::Constant
| 41 42 43 | # File 'lib/sequel/extensions/constant_sql_override.rb', line 41 def set_constant_sql(constant, override) @constant_sqls[constant.constant] = override end |