Sha256: eddeb2fad8b66eba402d73738615da7f37bd95c69fa2d1f15345a50ccfed4771

Contents?: true

Size: 559 Bytes

Versions: 8

Compression:

Stored size: 559 Bytes

Contents

module Api::Deprecated
  extend ActiveSupport::Concern

  class_methods do
    attr_accessor :deprecated_actions

    def deprecate(*actions)
      self.deprecated_actions ||= {}
      self.deprecated_actions[to_s] = actions
    end
  end

  included do
    after_action :deprecate_actions

    def deprecate_actions
      return unless self.class.deprecated_actions

      deprecated_actions = self.class.deprecated_actions[self.class.to_s]
      response.headers["Deprecated"] = true if deprecated_actions.include?(params[:action].to_sym)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
power_api-2.1.1 app/controllers/concerns/api/deprecated.rb
power_api-2.1.0 app/controllers/concerns/api/deprecated.rb
power_api-2.0.2 app/controllers/concerns/api/deprecated.rb
power_api-2.0.1 app/controllers/concerns/api/deprecated.rb
power_api-2.0.0 app/controllers/concerns/api/deprecated.rb
power_api-1.0.0 app/controllers/concerns/api/deprecated.rb
power_api-0.2.0 app/controllers/concerns/api/deprecated.rb
power_api-0.1.0 app/controllers/concerns/api/deprecated.rb