class Flipper::Types::Group
Attributes
name[R]
Public Class Methods
new(name, &block)
click to toggle source
# File lib/flipper/types/group.rb, line 11 def initialize(name, &block) @name = name.to_sym @value = @name if block_given? @block = block @single_argument = @block.arity.abs == 1 else @block = ->(_thing, _context) { false } @single_argument = false end end
wrap(group_or_name)
click to toggle source
# File lib/flipper/types/group.rb, line 4 def self.wrap(group_or_name) return group_or_name if group_or_name.is_a?(self) Flipper.group(group_or_name) end
Public Instance Methods
match?(thing, context)
click to toggle source
# File lib/flipper/types/group.rb, line 24 def match?(thing, context) if @single_argument @block.call(thing) else @block.call(thing, context) end end