Skip to content

Flipper.register should match any truthy value, not just true #110

@gareth

Description

@gareth

We recently wrote something like the following, hoping to set a generic group for flipper usage.

Flipper.register(:reviewers) do |actor|
  actor.try(:email) =~ /@example.com\z/
end

It didn't work, because String#=~ returns an integer (the position of the match in the string) rather than true/false. Flipper groups only respond if the register block explicitly returns true.

This seems a bit unrubyish, so I wondered if there was a specific reason that only true was allowed rather than (IMO) the more usual convention of any truthy value?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions