Sha256: 0e0c60c3667c133034bafab980e4d2a0d181af712196fb6453cab464f0895ec2
Contents?: true
Size: 838 Bytes
Versions: 2
Compression:
Stored size: 838 Bytes
Contents
require "sequel/enhancements" module Sequel module Plugins module StringDowncaser def self.apply(model, *args) model.instance_eval do @downcase_columns = Set.new end end def self.configure(model, column) model.add_downcase_column column end module ClassMethods Plugins.inherited_instance_variables(self, :@downcase_columns => :dup) def add_downcase_column(column) @downcase_columns << column end def downcase_column?(column) @downcase_columns.include? column end end module InstanceMethods def []=(k, v) if model.downcase_column?(k) && v.is_a?(String) && !v.is_a?(SQL::Blob) v = v.downcase end super end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sequel-enhancements-0.3.0 | lib/sequel/plugins/string_downcaser.rb |
sequel-enhancements-0.2.0 | lib/sequel/plugins/string_downcaser.rb |