Sha256: 95a721b9a92f390dd8512f4aabdf27fd5a8506991fdaf2b645892fa9b9e094ce

Contents?: true

Size: 615 Bytes

Versions: 5

Compression:

Stored size: 615 Bytes

Contents

require 'action_dispatch'

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

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

      actions
    end
  end
end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
destroyed_at-2.1.0 lib/destroyed_at/routes.rb
destroyed_at-2.0.0 lib/destroyed_at/routes.rb
destroyed_at-1.0.2 lib/destroyed_at/routes.rb
destroyed_at-1.0.1 lib/destroyed_at/routes.rb
destroyed_at-1.0.0 lib/destroyed_at/routes.rb