Sha256: 9ad608573017bc399ca3c0cbf42758a3be2dd6ba9ebfb3595a21ee33f33d6c0b

Contents?: true

Size: 891 Bytes

Versions: 13

Compression:

Stored size: 891 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)
        raise ArgumentError, 'thing cannot be nil' if thing.nil?

        unless thing.respond_to?(:flipper_id)
          raise ArgumentError, "#{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

      if RUBY_VERSION >= '3.0'
        def method_missing(name, *args, **kwargs, &block)
          @thing.send name, *args, **kwargs, &block
        end
      else
        def method_missing(name, *args, &block)
          @thing.send name, *args, &block
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
flipper-0.27.1 lib/flipper/types/actor.rb
flipper-0.27.0 lib/flipper/types/actor.rb
flipper-0.26.2 lib/flipper/types/actor.rb
flipper-0.26.1 lib/flipper/types/actor.rb
flipper-0.26.0 lib/flipper/types/actor.rb
flipper-0.26.0.rc2 lib/flipper/types/actor.rb
flipper-0.26.0.rc1 lib/flipper/types/actor.rb
flipper-0.25.4 lib/flipper/types/actor.rb
flipper-0.25.3 lib/flipper/types/actor.rb
flipper-0.25.2 lib/flipper/types/actor.rb
flipper-0.25.1 lib/flipper/types/actor.rb
flipper-0.25.0 lib/flipper/types/actor.rb
flipper-0.24.1 lib/flipper/types/actor.rb