module Sequel::Plugins::BlacklistSecurity::InstanceMethods

Public Instance Methods

set_except(hash, *except) click to toggle source

Set all values using the entries in the hash, except for the keys given in except. You should probably use set_fields instead of this method, as blacklist approaches to security are a bad idea.

artist.set_except({name: 'Jim'}, :hometown)
artist.name # => 'Jim'
   # File lib/sequel/plugins/blacklist_security.rb
75 def set_except(hash, *except)
76   set_restricted(hash, ExceptionList.new(except.flatten))
77 end
update_except(hash, *except) click to toggle source

Update all values using the entries in the hash, except for the keys given in except. You should probably use update_fields instead of this method, as blacklist approaches to security are a bad idea.

artist.update_except({name: 'Jim'}, :hometown) # UPDATE artists SET name = 'Jim' WHERE (id = 1)
   # File lib/sequel/plugins/blacklist_security.rb
84 def update_except(hash, *except)
85   update_restricted(hash, ExceptionList.new(except.flatten))
86 end

Private Instance Methods

setter_methods(type) click to toggle source

If set_except or update_except was used, remove the related methods from the list.

Calls superclass method
    # File lib/sequel/plugins/blacklist_security.rb
 91 def setter_methods(type)
 92   if type.is_a?(ExceptionList)
 93     meths = super(:all)
 94     meths -= Array(primary_key).map{|x| "#{x}="} if primary_key && model.restrict_primary_key?
 95     meths -= type.map{|x| "#{x}="}
 96     meths
 97   else
 98     super
 99   end
100 end