Sha256: fcf6e9b6c811c807e1a2afd1948654d10a18c22d58d030af4c43caf9d147ef20

Contents?: true

Size: 793 Bytes

Versions: 49

Compression:

Stored size: 793 Bytes

Contents

module Flipper
  module Api
    module V1
      module Decorators
        class Actor < SimpleDelegator
          # Public: the actor and features.
          attr_reader :actor, :features

          def initialize(actor, features)
            @actor = actor
            @features = features
          end

          def as_json
            {
              'flipper_id' => actor.flipper_id,
              'features' => features_data,
            }
          end

          private

          def features_data
            features.each_with_object({}) do |feature, features_hash|
              features_hash[feature.name] = {
                'enabled' => feature.enabled?(actor),
              }
              features_hash
            end
          end
        end
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
flipper-api-1.2.2 lib/flipper/api/v1/decorators/actor.rb
flipper-api-1.2.1 lib/flipper/api/v1/decorators/actor.rb
flipper-api-1.2.0 lib/flipper/api/v1/decorators/actor.rb
flipper-api-1.1.2 lib/flipper/api/v1/decorators/actor.rb
flipper-api-1.1.1 lib/flipper/api/v1/decorators/actor.rb
flipper-api-1.1.0 lib/flipper/api/v1/decorators/actor.rb
flipper-api-1.0.0 lib/flipper/api/v1/decorators/actor.rb
flipper-api-1.0.0.pre lib/flipper/api/v1/decorators/actor.rb
flipper-api-0.28.3 lib/flipper/api/v1/decorators/actor.rb
flipper-api-0.28.2 lib/flipper/api/v1/decorators/actor.rb
flipper-api-0.28.1 lib/flipper/api/v1/decorators/actor.rb
flipper-api-0.28.0 lib/flipper/api/v1/decorators/actor.rb
flipper-api-0.27.1 lib/flipper/api/v1/decorators/actor.rb
flipper-api-0.27.0 lib/flipper/api/v1/decorators/actor.rb
flipper-api-0.26.2 lib/flipper/api/v1/decorators/actor.rb
flipper-api-0.26.1 lib/flipper/api/v1/decorators/actor.rb
flipper-api-0.26.0 lib/flipper/api/v1/decorators/actor.rb
flipper-api-0.26.0.rc2 lib/flipper/api/v1/decorators/actor.rb
flipper-api-0.26.0.rc1 lib/flipper/api/v1/decorators/actor.rb
flipper-api-0.25.4 lib/flipper/api/v1/decorators/actor.rb