File: boolean_gate.rb

package info (click to toggle)
ruby-flipper 0.25.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,236 kB
  • sloc: ruby: 15,977; sh: 58; javascript: 24; makefile: 14
file content (30 lines) | stat: -rw-r--r-- 787 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'flipper/api/action'
require 'flipper/api/v1/decorators/feature'

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

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

          def post
            feature = flipper[feature_name]
            feature.enable
            decorated_feature = Decorators::Feature.new(feature)
            json_response(decorated_feature.as_json, 200)
          end

          def delete
            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