Sha256: bef37133dc107b37959e4aa5f3eb064734382b2f948bc4b6a49040e683037e08

Contents?: true

Size: 711 Bytes

Versions: 42

Compression:

Stored size: 711 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

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

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
flipper-0.11.0.beta3 lib/flipper/types/actor.rb
flipper-0.11.0.beta1 lib/flipper/types/actor.rb