Sha256: 1c1a276297268c3159804dd77a82da8186a3a3642e6236c0c0c81873b3586b4f

Contents?: true

Size: 803 Bytes

Versions: 25

Compression:

Stored size: 803 Bytes

Contents

require 'flipper/api/action'
require 'flipper/api/v1/decorators/feature'

module Flipper
  module Api
    module V1
      module Actions
        class Feature < Api::Action
          include FeatureNameFromRoute

          route %r{\A/features/(?<feature_name>.*)/?\Z}

          def get
            return json_error_response(:feature_not_found) unless feature_exists?(feature_name)
            feature = Decorators::Feature.new(flipper[feature_name])
            json_response(feature.as_json)
          end

          def delete
            flipper.remove(feature_name)
            json_response({}, 204)
          end

          private

          def feature_exists?(feature_name)
            flipper.features.map(&:key).include?(feature_name)
          end
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
flipper-api-0.24.0 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.23.1 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.23.0 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.22.2 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.22.1 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.22.0 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.21.0 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.21.0.rc2 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.21.0.rc1 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.20.4 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.20.3 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.20.2 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.20.1 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.20.0 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.20.0.beta3 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.20.0.beta2 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.20.0.beta1 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.19.1 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.19.0 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.18.0 lib/flipper/api/v1/actions/feature.rb