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

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

Instance Method Summary collapse

Instance Method Details

#after_destroyObject

Clear the instance filters after successfully destroying the object.



51
52
53
54
# File 'lib/sequel/plugins/instance_filters.rb', line 51

def after_destroy
  super
  clear_instance_filters
end

#after_updateObject

Clear the instance filters after successfully updating the object.



57
58
59
60
# File 'lib/sequel/plugins/instance_filters.rb', line 57

def after_update
  super
  clear_instance_filters
end

#dupObject

Duplicate internal structures when duplicating model instance.



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

def dup
  ifs = instance_filters.dup
  super.instance_eval do
    @instance_filters = ifs
    self
  end
end

#freezeObject

Freeze the instance filters when freezing the object



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

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.



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

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