Sha256: edeb94e755f6383a4535bc771a0d43947ee2c61072be6c2d5e56c3fe421718ce

Contents?: true

Size: 741 Bytes

Versions: 15

Compression:

Stored size: 741 Bytes

Contents

module Flipper
  module Types
    class Actor < Type
      def self.wrappable?(thing)
        return false if thing.nil?
        thing.respond_to?(:flipper_id)
      end

      attr_reader :thing

      def initialize(thing)
        if thing.nil?
          raise ArgumentError.new("thing cannot be nil")
        end

        unless thing.respond_to?(:flipper_id)
          raise ArgumentError.new("#{thing.inspect} must respond to flipper_id, but does not")
        end

        @thing = thing
        @value = thing.flipper_id.to_s
      end

      def respond_to?(*args)
        super || @thing.respond_to?(*args)
      end

      def method_missing(name, *args, &block)
        @thing.send name, *args, &block
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
flipper-0.10.2 lib/flipper/types/actor.rb
flipper-0.10.1 lib/flipper/types/actor.rb
flipper-0.10.0 lib/flipper/types/actor.rb
flipper-0.9.2 lib/flipper/types/actor.rb
flipper-0.9.1 lib/flipper/types/actor.rb
flipper-0.9.0 lib/flipper/types/actor.rb
flipper-0.9.0.beta1 lib/flipper/types/actor.rb
flipper-0.8.0 lib/flipper/types/actor.rb
flipper-0.7.5 lib/flipper/types/actor.rb
flipper-0.7.4 lib/flipper/types/actor.rb
flipper-0.7.3 lib/flipper/types/actor.rb
flipper-0.7.2 lib/flipper/types/actor.rb
flipper-0.7.1 lib/flipper/types/actor.rb
flipper-0.7.0 lib/flipper/types/actor.rb
flipper-0.7.0.beta6 lib/flipper/types/actor.rb