Sha256: a3f65604819dc3bcaada679775a6831815c72263e9826969b4fa2ccc573397dc

Contents?: true

Size: 669 Bytes

Versions: 1

Compression:

Stored size: 669 Bytes

Contents

require 'action_dispatch'

module DestroyedAt::Routes
  def set_member_mappings_for_resource
    member do
      put :restore if parent_resource.actions.include?(:restore)
    end
    super
  end
end

ActionDispatch::Routing::Mapper.send(:prepend, DestroyedAt::Routes)

module DestroyedAt::Resource
  def default_actions
    actions = super
    if self.name.camelcase.singularize.constantize.included_modules.include?(DestroyedAt)
      actions << :restore
    end

    actions
  end
end

ActionDispatch::Routing::Mapper::Resources::SingletonResource.send(:prepend, DestroyedAt::Resource)
ActionDispatch::Routing::Mapper::Resource.send(:prepend, DestroyedAt::Resource)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
destroyed_at-0.3.0 lib/destroyed_at/mapper.rb