Module: Softie

Extended by:
ActiveSupport::Concern
Defined in:
lib/softie.rb,
lib/softie/version.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

VERSION =
"1.0.0"

Instance Method Summary collapse

Instance Method Details

#deleted(options = {}) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/softie.rb', line 30

def deleted(options = {})
  public_send("#{softie_options[:key]}=", Time.now.utc)

  if softie_options[:deleted_by_class]
    public_send("#{softie_options[:deleted_by_key]}=", options.delete(:by))
  end
end

#deleted!(options = {}) ⇒ Object



38
39
40
41
# File 'lib/softie.rb', line 38

def deleted!(options = {})
  deleted(options)
  save
end

#deleted?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/softie.rb', line 56

def deleted?
  public_send(softie_options[:key]) != nil
end

#restoreObject



43
44
45
46
47
48
49
# File 'lib/softie.rb', line 43

def restore
  public_send("#{softie_options[:key]}=", nil)

  if softie_options[:deleted_by_class]
    public_send("#{softie_options[:deleted_by_key]}=", nil)
  end
end

#restore!Object



51
52
53
54
# File 'lib/softie.rb', line 51

def restore!
  restore
  save
end