Sha256: b2e1befcdd9123380954fb42bdb596c0b475371540b6b7fd547fc4d938661b52

Contents?: true

Size: 691 Bytes

Versions: 8

Compression:

Stored size: 691 Bytes

Contents

require 'delegate'
require 'flipper/api/v1/decorators/gate'

module Flipper
  module Api
    module V1
      module Decorators
        class Feature < SimpleDelegator

          # Public: The feature being decorated.
          alias_method :feature, :__getobj__

          # Public: Returns instance as hash that is ready to be json dumped.
          def as_json
            gate_values = feature.gate_values
            {
              'key' => key,
              'state' => state.to_s,
              'gates' => gates.map { |gate|
                Decorators::Gate.new(gate, gate_values[gate.key]).as_json
              },
            }
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
flipper-api-0.10.2 lib/flipper/api/v1/decorators/feature.rb
flipper-api-0.10.1 lib/flipper/api/v1/decorators/feature.rb
flipper-api-0.10.0 lib/flipper/api/v1/decorators/feature.rb
flipper-api-0.9.2 lib/flipper/api/v1/decorators/feature.rb
flipper-api-0.9.1 lib/flipper/api/v1/decorators/feature.rb
flipper-api-0.9.0 lib/flipper/api/v1/decorators/feature.rb
flipper-api-0.9.0.beta1 lib/flipper/api/v1/decorators/feature.rb
flipper-api-0.8.0 lib/flipper/api/v1/decorators/feature.rb