Class: Handcart::Strategies::InclusionStrategy
- Inherits:
-
BaseIpStrategy
- Object
- BaseIpStrategy
- Handcart::Strategies::InclusionStrategy
- Defined in:
- lib/handcart/strategies/inclusion_strategy.rb
Instance Attribute Summary
Attributes inherited from BaseIpStrategy
Instance Method Summary collapse
-
#initialize ⇒ InclusionStrategy
constructor
This strategy checks the permitted list of IP Addresses for the current handcart to insure not only that the list contains the foreign IP address, but that it is also within the same subnet group.
- #is_in_range?(foreign_ip_address, handcart) ⇒ Boolean
Methods inherited from BaseIpStrategy
Constructor Details
#initialize ⇒ InclusionStrategy
This strategy checks the permitted list of IP Addresses for the current handcart to insure not only that the list contains the foreign IP address, but that it is also within the same subnet group.
8 9 10 |
# File 'lib/handcart/strategies/inclusion_strategy.rb', line 8 def initialize @strategy = :inclusion end |
Instance Method Details
#is_in_range?(foreign_ip_address, handcart) ⇒ Boolean
12 13 14 |
# File 'lib/handcart/strategies/inclusion_strategy.rb', line 12 def is_in_range?(foreign_ip_address, handcart) handcart.ip_addresses.permitted.any? { |handcart_ip_address| IPAddr.new("#{handcart_ip_address.address}/#{handcart_ip_address.subnet_mask}").include?(foreign_ip_address) } end |