Module: Sequel::Plugins::InstanceFilters::InstanceMethods

Defined in:
lib/sequel/plugins/instance_filters.rb

Instance Method Summary collapse

Instance Method Details

#after_destroy ⇒ Object

Clear the instance filters after successfully destroying the object.



59
60
61
62
# File 'lib/sequel/plugins/instance_filters.rb', line 59

def after_destroy
  super
  clear_instance_filters
end

#after_update ⇒ Object

Clear the instance filters after successfully updating the object.



65
66
67
68
# File 'lib/sequel/plugins/instance_filters.rb', line 65

def after_update
  super
  clear_instance_filters
end

#freeze ⇒ Object

Freeze the instance filters when freezing the object



71
72
73
74
# File 'lib/sequel/plugins/instance_filters.rb', line 71

def freeze
  instance_filters.freeze
  super
end

#instance_filter(*args, &block) ⇒ Object

Add an instance filter to the array of instance filters Both the arguments given and the block are passed to the dataset's filter method.



79
80
81
# File 'lib/sequel/plugins/instance_filters.rb', line 79

def instance_filter(*args, &block)
  instance_filters << [args, block]
end

#save_changes(opts = OPTS) ⇒ Object

Clear instance filters when saving changes even if the object wasn't modified.



85
86
87
88
89
# File 'lib/sequel/plugins/instance_filters.rb', line 85

def save_changes(opts=OPTS)
  ret = super
  clear_instance_filters if ret.nil?
  ret
end