Class: Keycard::InstitutionFinder
- Inherits:
-
Object
- Object
- Keycard::InstitutionFinder
- Defined in:
- lib/keycard/institution_finder.rb
Overview
looks up institution ID(s) by IP address
Constant Summary collapse
- IDENTITY_ATTRS =
%i[dlpsInstitutionId].freeze
- INST_QUERY =
<<~SQL SELECT inst FROM aa_network WHERE ? >= dlpsAddressStart AND ? <= dlpsAddressEnd AND dlpsAccessSwitch = 'allow' AND dlpsDeleted = 'f' AND inst is not null AND inst NOT IN ( SELECT inst FROM aa_network WHERE ? >= dlpsAddressStart AND ? <= dlpsAddressEnd AND dlpsAccessSwitch = 'deny' AND dlpsDeleted = 'f' ) SQL
Instance Method Summary collapse
- #attributes_for(request) ⇒ Object
- #identity_keys ⇒ Object
-
#initialize(db: Keycard::DB.db) ⇒ InstitutionFinder
constructor
A new instance of InstitutionFinder.
Constructor Details
#initialize(db: Keycard::DB.db) ⇒ InstitutionFinder
Returns a new instance of InstitutionFinder.
24 25 26 27 |
# File 'lib/keycard/institution_finder.rb', line 24 def initialize(db: Keycard::DB.db) @db = db @stmt = @db[INST_QUERY, *[:$client_ip] * 4].prepare(:select, :unused) end |
Instance Method Details
#attributes_for(request) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/keycard/institution_finder.rb', line 33 def attributes_for(request) return {} unless (numeric_ip = numeric_ip(request.client_ip)) insts = insts_for_ip(numeric_ip) if !insts.empty? { dlpsInstitutionId: insts } else {} end end |
#identity_keys ⇒ Object
29 30 31 |
# File 'lib/keycard/institution_finder.rb', line 29 def identity_keys IDENTITY_ATTRS end |