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



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

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

#<(other) ⇒ Object



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

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

#<=(other) ⇒ Object



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

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

#==(other) ⇒ Object



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

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

#>(other) ⇒ Object



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

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

#>=(other) ⇒ Object



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

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

#apply_to(attribute) ⇒ Object



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

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