Skip to content

Commit

Permalink
create an include expression
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloancheta committed Jun 18, 2024
1 parent 5aa9cfd commit f39b846
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/flipper/expression/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def less_than_or_equal_to(object)
alias lte less_than_or_equal_to
alias less_than_or_equal less_than_or_equal_to

def include(object)
build({ Include: [self, object] })
end

def percentage_of_actors(object)
build({ PercentageOfActors: [self, build(object)] })
end
Expand Down
9 changes: 9 additions & 0 deletions lib/flipper/expressions/include.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Flipper
module Expressions
class Include < Comparable
def self.operator
:include?
end
end
end
end
13 changes: 13 additions & 0 deletions spec/flipper/expression_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@
])
end

it "can build Include" do
expression = described_class.build({
"Inlcude" => [["hello"], "hello"]
})

expect(expression).to be_instance_of(Flipper::Expression)
expect(expression.function).to be(Flipper::Expressions::Include)
expect(expression.args).to eq([
Flipper.constant(["hello"]),
Flipper.constant("hello"),
])
end

it "can build NotEqual" do
expression = described_class.build({
"NotEqual" => [
Expand Down

0 comments on commit f39b846

Please sign in to comment.