Module: Ardm::Property::ParanoidBase::ClassMethods

Defined in:
lib/ardm/property/support/paranoid_base.rb

Instance Method Summary collapse

Instance Method Details

#inherited(model) ⇒ Object



36
37
38
39
40
# File 'lib/ardm/property/support/paranoid_base.rb', line 36

def inherited(model)
  model.instance_variable_set(:@paranoid_properties, @paranoid_properties.dup)
  model.instance_variable_set(:@paranoid_scopes, @paranoid_scopes.dup)
  super
end

#paranoid_propertiesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



57
58
59
# File 'lib/ardm/property/support/paranoid_base.rb', line 57

def paranoid_properties
  @paranoid_properties
end

#paranoid_scopesObject



61
62
63
# File 'lib/ardm/property/support/paranoid_base.rb', line 61

def paranoid_scopes
  @paranoid_scopes
end

#set_paranoid_property(name, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



66
67
68
# File 'lib/ardm/property/support/paranoid_base.rb', line 66

def set_paranoid_property(name, &block)
  paranoid_properties[name] = block
end

#set_paranoid_scope(conditions) ⇒ Object



70
71
72
73
74
# File 'lib/ardm/property/support/paranoid_base.rb', line 70

def set_paranoid_scope(conditions)
  paranoid_scope = conditions
  paranoid_scopes << paranoid_scope
  default_scope { where(paranoid_scope) }
end

#with_deleted(&block) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ardm/property/support/paranoid_base.rb', line 43

def with_deleted(&block)
  with_deleted_scope = self.all.with_default_scope
  paranoid_scopes.each do |cond|
    with_deleted_scope.where_values.delete(cond)
  end

  if block_given?
    with_deleted_scope.scoping(&block)
  else
    with_deleted_scope.all
  end
end