Sha256: d142c54448c010c37eb0e344cbe2e44ccf010e7260ba528e4fe7d50ab006f05a

Contents?: true

Size: 905 Bytes

Versions: 29

Compression:

Stored size: 905 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)
            exclude_gates = params['exclude_gates']&.downcase == "true"
            feature = Decorators::Feature.new(flipper[feature_name])
            json_response(feature.as_json(exclude_gates: exclude_gates))
          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

29 entries across 29 versions & 1 rubygems

Version Path
flipper-api-1.3.2 lib/flipper/api/v1/actions/feature.rb
flipper-api-1.3.1 lib/flipper/api/v1/actions/feature.rb
flipper-api-1.3.0 lib/flipper/api/v1/actions/feature.rb
flipper-api-1.3.0.pre lib/flipper/api/v1/actions/feature.rb
flipper-api-1.2.2 lib/flipper/api/v1/actions/feature.rb
flipper-api-1.2.1 lib/flipper/api/v1/actions/feature.rb
flipper-api-1.2.0 lib/flipper/api/v1/actions/feature.rb
flipper-api-1.1.2 lib/flipper/api/v1/actions/feature.rb
flipper-api-1.1.1 lib/flipper/api/v1/actions/feature.rb
flipper-api-1.1.0 lib/flipper/api/v1/actions/feature.rb
flipper-api-1.0.0 lib/flipper/api/v1/actions/feature.rb
flipper-api-1.0.0.pre lib/flipper/api/v1/actions/feature.rb
flipper-api-0.28.3 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.28.2 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.28.1 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.28.0 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.27.1 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.27.0 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.26.2 lib/flipper/api/v1/actions/feature.rb
flipper-api-0.26.1 lib/flipper/api/v1/actions/feature.rb