Sha256: 1468d0f4da6515348a5a714b7bbf767574d3e26423421f601f0bacc00917d135

Contents?: true

Size: 708 Bytes

Versions: 8

Compression:

Stored size: 708 Bytes

Contents

module EntryDeletion
  include Nyanko::Unit

  scope(:view) do
    function(:delete_link) do
      render "/delete_link", :entry => entry if entry.persisted?
    end
  end

  scope(:controller) do
    function(:destroy) do
      entry = Entry.find(params[:id])
      entry.unit.soft_delete
      redirect_to entries_path
    end

    function(:index) do
      @entries = Entry.unit.active
    end
  end

  models do
    expand(:Entry) do
      scope :active, lambda { where(:deleted_at => nil) }

      def soft_delete
        update_attributes(:deleted_at => Time.now)
      end
    end
  end

  helpers do
    def link_to_deletion(entry)
      link_to "Delete", entry, :method => :delete
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
nyanko-0.0.9 spec/dummy/app/units/entry_deletion/entry_deletion.rb
nyanko-0.0.8 spec/dummy/app/units/entry_deletion/entry_deletion.rb
nyanko-0.0.7 spec/dummy/app/units/entry_deletion/entry_deletion.rb
nyanko-0.0.6 spec/dummy/app/units/entry_deletion/entry_deletion.rb
nyanko-0.0.5 spec/dummy/app/units/entry_deletion/entry_deletion.rb
nyanko-0.0.4 spec/dummy/app/units/entry_deletion/entry_deletion.rb
nyanko-0.0.3 spec/dummy/app/units/entry_deletion/entry_deletion.rb
nyanko-0.0.1 spec/dummy/app/units/entry_deletion/entry_deletion.rb