Sha256: 1e7b9759f3a1f530a3cc9df907669b45e5bdb2cf3c698e4a0a52cef341ac1342

Contents?: true

Size: 865 Bytes

Versions: 3

Compression:

Stored size: 865 Bytes

Contents

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

module Flipper
  module Api
    module V1
      module Actions
        class BooleanGate < Api::Action
          route %r{api/v1/features/[^/]*/boolean/?\Z}

          def post
            feature_name = Rack::Utils.unescape(path_parts[-2])
            feature = flipper[feature_name]
            feature.enable
            decorated_feature = Decorators::Feature.new(feature)
            json_response(decorated_feature.as_json, 200)
          end

          def delete
            feature_name = Rack::Utils.unescape(path_parts[-2])
            feature = flipper[feature_name.to_sym]
            feature.disable
            decorated_feature = Decorators::Feature.new(feature)
            json_response(decorated_feature.as_json, 200)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flipper-api-0.10.2 lib/flipper/api/v1/actions/boolean_gate.rb
flipper-api-0.10.1 lib/flipper/api/v1/actions/boolean_gate.rb
flipper-api-0.10.0 lib/flipper/api/v1/actions/boolean_gate.rb