Class: Arspy::Operators::AttributeTest::RangeTest

Inherits:
Base
  • Object
show all
Defined in:
lib/arspy/operators/attribute_test/range_test.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Arspy::Operators::AttributeTest::Base

Class Method Details

.applies?(param) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/arspy/operators/attribute_test/range_test.rb', line 8

def self.applies?(param)
  param.is_a? Range
end

Instance Method Details

#match?(value_or_object) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
# File 'lib/arspy/operators/attribute_test/range_test.rb', line 12

def match?(value_or_object)
  case value_or_object
  when ActiveRecord::Base
    @param.include?(value_or_object.id)
  else
    @param.include?(value_or_object.to_i)
  end
end