Sha256: 70540396a9c44ed10cb79624149b99524abf35a03fa96bd4bb3e9653e5ddc0a7
Contents?: true
Size: 903 Bytes
Versions: 16
Compression:
Stored size: 903 Bytes
Contents
module Flipper module Types class Group < Type def self.wrap(group_or_name) return group_or_name if group_or_name.is_a?(self) Flipper.group(group_or_name) end attr_reader :name def initialize(name, &block) @name = name.to_sym @value = @name if block_given? @block = block @single_argument = call_with_no_context?(@block) else @block = ->(actor, context) { false } @single_argument = false end end def match?(actor, context) if @single_argument @block.call(actor) else @block.call(actor, context) end end NO_PARAMS_IN_RUBY_3 = [[:req], [:rest]] def call_with_no_context?(block) return true if block.parameters == NO_PARAMS_IN_RUBY_3 block.arity.abs == 1 end end end end
Version data entries
16 entries across 16 versions & 1 rubygems