Sha256: 2c40fcf462f11ac2fa88da389305ba100b7030e15587e2e5152d859e2368148e

Contents?: true

Size: 715 Bytes

Versions: 2

Compression:

Stored size: 715 Bytes

Contents

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

      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

2 entries across 2 versions & 1 rubygems

Version Path
flipper-0.7.0.beta5 lib/flipper/types/actor.rb
flipper-0.7.0.beta4 lib/flipper/types/actor.rb