Sha256: 16d98df69887883bc4e193167092e984b51c9ea946cd5f74c81b797c4800477c

Contents?: true

Size: 727 Bytes

Versions: 5

Compression:

Stored size: 727 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
    class_name = self.singular.camelcase

    if Module.const_defined?(class_name) && class_name.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

5 entries across 5 versions & 1 rubygems

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