Sha256: fba2b3eb166b15d71447f162730921836e2c02850d2b7ffddd5c54852cdb9e51

Contents?: true

Size: 1.2 KB

Versions: 17

Compression:

Stored size: 1.2 KB

Contents

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

module Flipper
  module Api
    module V1
      module Actions
        class ActorsGate < Api::Action
          route %r{features/[^/]*/actors/?\Z}

          def post
            ensure_valid_params
            feature = flipper[feature_name]
            actor = Actor.new(flipper_id)
            feature.enable_actor(actor)
            decorated_feature = Decorators::Feature.new(feature)
            json_response(decorated_feature.as_json, 200)
          end

          def delete
            ensure_valid_params
            feature = flipper[feature_name]
            actor = Actor.new(flipper_id)
            feature.disable_actor(actor)
            decorated_feature = Decorators::Feature.new(feature)
            json_response(decorated_feature.as_json, 200)
          end

          private

          def ensure_valid_params
            json_error_response(:flipper_id_invalid) if flipper_id.nil?
          end

          def feature_name
            @feature_name ||= Rack::Utils.unescape(path_parts[-2])
          end

          def flipper_id
            @flipper_id ||= params['flipper_id']
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
flipper-api-0.15.0 lib/flipper/api/v1/actions/actors_gate.rb
flipper-api-0.14.0 lib/flipper/api/v1/actions/actors_gate.rb
flipper-api-0.13.0 lib/flipper/api/v1/actions/actors_gate.rb
flipper-api-0.13.0.beta1 lib/flipper/api/v1/actions/actors_gate.rb
flipper-api-0.12.2 lib/flipper/api/v1/actions/actors_gate.rb
flipper-api-0.12.1 lib/flipper/api/v1/actions/actors_gate.rb
flipper-api-0.12.0 lib/flipper/api/v1/actions/actors_gate.rb
flipper-api-0.11.0 lib/flipper/api/v1/actions/actors_gate.rb
flipper-api-0.11.0.rc1 lib/flipper/api/v1/actions/actors_gate.rb
flipper-api-0.11.0.beta9 lib/flipper/api/v1/actions/actors_gate.rb
flipper-api-0.11.0.beta8 lib/flipper/api/v1/actions/actors_gate.rb
flipper-api-0.11.0.beta7 lib/flipper/api/v1/actions/actors_gate.rb
flipper-api-0.11.0.beta6 lib/flipper/api/v1/actions/actors_gate.rb
flipper-api-0.11.0.beta5 lib/flipper/api/v1/actions/actors_gate.rb
flipper-api-0.11.0.beta4 lib/flipper/api/v1/actions/actors_gate.rb
flipper-api-0.11.0.beta3 lib/flipper/api/v1/actions/actors_gate.rb
flipper-api-0.11.0.beta1 lib/flipper/api/v1/actions/actors_gate.rb