Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an Include Expression #871

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading