Class: ActsAsRecursiveTree::Options::DepthCondition

Inherits:
Object
  • Object
show all
Defined in:
lib/acts_as_recursive_tree/options/depth_condition.rb

Instance Method Summary collapse

Instance Method Details

#!=(other) ⇒ Object



10
11
12
13
# File 'lib/acts_as_recursive_tree/options/depth_condition.rb', line 10

def !=(other)
  @value     = Values.create(other)
  @operation = false
end

#<(other) ⇒ Object



15
16
17
18
# File 'lib/acts_as_recursive_tree/options/depth_condition.rb', line 15

def <(other)
  @value     = other
  @operation = :lt
end

#<=(other) ⇒ Object



20
21
22
23
# File 'lib/acts_as_recursive_tree/options/depth_condition.rb', line 20

def <=(other)
  @value     = other
  @operation = :lteq
end

#==(other) ⇒ Object



5
6
7
8
# File 'lib/acts_as_recursive_tree/options/depth_condition.rb', line 5

def ==(other)
  @value     = Values.create(other)
  @operation = true
end

#>(other) ⇒ Object



25
26
27
28
# File 'lib/acts_as_recursive_tree/options/depth_condition.rb', line 25

def >(other)
  @value     = other
  @operation = :gt
end

#>=(other) ⇒ Object



30
31
32
33
# File 'lib/acts_as_recursive_tree/options/depth_condition.rb', line 30

def >=(other)
  @value     = other
  @operation = :gteq
end

#apply_to(attribute) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/acts_as_recursive_tree/options/depth_condition.rb', line 35

def apply_to(attribute)
  if @value.is_a?(Values::Base)
    if @operation
      @value.apply_to(attribute)
    else
      @value.apply_negated_to(attribute)
    end
  else
    attribute.send(@operation, @value)
  end
end