Sha256: 75614c043de16750d50f91e1706b0658c769caf2c0584b13d735123f9c99d405

Contents?: true

Size: 1.15 KB

Versions: 54

Compression:

Stored size: 1.15 KB

Contents

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

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

          route %r{\A/features/(?<feature_name>.*)/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 flipper_id
            @flipper_id ||= params['flipper_id']
          end
        end
      end
    end
  end
end

Version data entries

54 entries across 54 versions & 1 rubygems

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