Module: Flipper::Expression::Builder

Included in:
Flipper::Expression, Constant
Defined in:
lib/flipper/expression/builder.rb

Instance Method Summary collapse

Instance Method Details

#add(*expressions) ⇒ Object



8
9
10
# File 'lib/flipper/expression/builder.rb', line 8

def add(*expressions)
  group? ? build(name => args + expressions.flatten) : any.add(*expressions)
end

#allObject



20
21
22
# File 'lib/flipper/expression/builder.rb', line 20

def all
  all? ? self : build({ All: [self] })
end

#all?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/flipper/expression/builder.rb', line 64

def all?
  is_a?(Expression) && function == Expressions::All
end

#anyObject



16
17
18
# File 'lib/flipper/expression/builder.rb', line 16

def any
  any? ? self : build({ Any: [self] })
end

#any?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/flipper/expression/builder.rb', line 60

def any?
  is_a?(Expression) && function == Expressions::Any
end

#build(object) ⇒ Object



4
5
6
# File 'lib/flipper/expression/builder.rb', line 4

def build(object)
  Expression.build(object)
end

#equal(object) ⇒ Object Also known as: eq



24
25
26
# File 'lib/flipper/expression/builder.rb', line 24

def equal(object)
  build({ Equal: [self, object] })
end

#greater_than(object) ⇒ Object Also known as: gt



34
35
36
# File 'lib/flipper/expression/builder.rb', line 34

def greater_than(object)
  build({ GreaterThan: [self, object] })
end

#greater_than_or_equal_to(object) ⇒ Object Also known as: gte, greater_than_or_equal



39
40
41
# File 'lib/flipper/expression/builder.rb', line 39

def greater_than_or_equal_to(object)
  build({ GreaterThanOrEqualTo: [self, object] })
end

#group?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/flipper/expression/builder.rb', line 68

def group?
  any? || all?
end

#less_than(object) ⇒ Object Also known as: lt



45
46
47
# File 'lib/flipper/expression/builder.rb', line 45

def less_than(object)
  build({ LessThan: [self, object] })
end

#less_than_or_equal_to(object) ⇒ Object Also known as: lte, less_than_or_equal



50
51
52
# File 'lib/flipper/expression/builder.rb', line 50

def less_than_or_equal_to(object)
  build({ LessThanOrEqualTo: [self, object] })
end

#not_equal(object) ⇒ Object Also known as: neq



29
30
31
# File 'lib/flipper/expression/builder.rb', line 29

def not_equal(object)
  build({ NotEqual: [self, object] })
end

#percentage_of_actors(object) ⇒ Object



56
57
58
# File 'lib/flipper/expression/builder.rb', line 56

def percentage_of_actors(object)
  build({ PercentageOfActors: [self, build(object)] })
end

#remove(*expressions) ⇒ Object



12
13
14
# File 'lib/flipper/expression/builder.rb', line 12

def remove(*expressions)
  group? ? build(name => args - expressions.flatten) : any.remove(*expressions)
end