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 or set_only 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, line 75
def set_except(hash, *except)
  set_restricted(hash, ExceptionList.new(except.flatten))
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 or update_only 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, line 84
def update_except(hash, *except)
  update_restricted(hash, ExceptionList.new(except.flatten))
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, line 91
def setter_methods(type)
  if type.is_a?(ExceptionList)
    meths = super(:all)
    meths -= Array(primary_key).map{|x| "#{x}="} if primary_key && model.restrict_primary_key?
    meths -= type.map{|x| "#{x}="}
    meths
  else
    super
  end
end