Module: Softy

Extended by:
ActiveSupport::Concern
Defined in:
lib/softy.rb,
lib/softy/version.rb,
lib/generators/softy/migration/migration_generator.rb

Defined Under Namespace

Modules: ClassMethods Classes: MigrationGenerator

Constant Summary collapse

VERSION =
"0.0.4"

Instance Method Summary collapse

Instance Method Details

#deleteObject



24
25
26
27
# File 'lib/softy.rb', line 24

def delete
  update_column(:deleted_at, Time.now) if !destroyed? && persisted?
  freeze
end

#destroyObject



20
21
22
# File 'lib/softy.rb', line 20

def destroy
  _run_destroy_callbacks { delete }
end

#destroyed?Boolean Also known as: deleted?

Returns:

  • (Boolean)


33
34
35
# File 'lib/softy.rb', line 33

def destroyed?
  !self.deleted_at.nil?
end

#has_softy?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/softy.rb', line 16

def has_softy?
  true
end

#persisted?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/softy.rb', line 12

def persisted?
  !new_record?
end

#restore!Object



29
30
31
# File 'lib/softy.rb', line 29

def restore!
  self.class.with_deleted.update_all({ deleted_at: nil }, self.class.primary_key => self.id) > 0
end