Class: Institution
- Inherits:
-
Struct
- Object
- Struct
- Institution
- Defined in:
- lib/authpds/institution.rb
Instance Attribute Summary collapse
-
#application_layout ⇒ Object
Returns the value of attribute application_layout.
-
#default_institution ⇒ Object
Returns the value of attribute default_institution.
-
#display_name ⇒ Object
Returns the value of attribute display_name.
-
#ip_addresses ⇒ Object
Returns the value of attribute ip_addresses.
-
#login_attributes ⇒ Object
Returns the value of attribute login_attributes.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent_institution ⇒ Object
Returns the value of attribute parent_institution.
-
#view_attributes ⇒ Object
Returns the value of attribute view_attributes.
Instance Method Summary collapse
-
#includes_ip?(prospective_ip_address) ⇒ Boolean
Check the list of IP addresses for the given IP.
-
#initialize(h = {}, controller) ⇒ Institution
constructor
Better initializer than Struct gives us, take a hash instead of an ordered array.
-
#instantiate_services! ⇒ Object
Instantiates a new copy of all services included in this institution, returns an array.
- #to_h ⇒ Object
Constructor Details
#initialize(h = {}, controller) ⇒ Institution
Better initializer than Struct gives us, take a hash instead of an ordered array. :services=>[] is an array of service ids, not actual Services!
7 8 9 10 11 12 |
# File 'lib/authpds/institution.rb', line 7 def initialize(h={}, controller) members.each {|m| self.send( ("#{m}=").to_sym , (h.delete(m.to_sym) || h.delete(m))) } default_institution = false unless default_institution # Log the fact that there are left overs in the hash # Rails.logger.warn("The following institution settings were ignored: #{h.inspect}.") unless h.empty? end |
Instance Attribute Details
#application_layout ⇒ Object
Returns the value of attribute application_layout
1 2 3 |
# File 'lib/authpds/institution.rb', line 1 def application_layout @application_layout end |
#default_institution ⇒ Object
Returns the value of attribute default_institution
1 2 3 |
# File 'lib/authpds/institution.rb', line 1 def default_institution @default_institution end |
#display_name ⇒ Object
Returns the value of attribute display_name
1 2 3 |
# File 'lib/authpds/institution.rb', line 1 def display_name @display_name end |
#ip_addresses ⇒ Object
Returns the value of attribute ip_addresses
1 2 3 |
# File 'lib/authpds/institution.rb', line 1 def ip_addresses @ip_addresses end |
#login_attributes ⇒ Object
Returns the value of attribute login_attributes
1 2 3 |
# File 'lib/authpds/institution.rb', line 1 def login_attributes @login_attributes end |
#name ⇒ Object
Returns the value of attribute name
1 2 3 |
# File 'lib/authpds/institution.rb', line 1 def name @name end |
#parent_institution ⇒ Object
Returns the value of attribute parent_institution
1 2 3 |
# File 'lib/authpds/institution.rb', line 1 def parent_institution @parent_institution end |
#view_attributes ⇒ Object
Returns the value of attribute view_attributes
1 2 3 |
# File 'lib/authpds/institution.rb', line 1 def view_attributes @view_attributes end |
Instance Method Details
#includes_ip?(prospective_ip_address) ⇒ Boolean
Check the list of IP addresses for the given IP
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/authpds/institution.rb', line 21 def includes_ip?(prospective_ip_address) return false if ip_addresses.nil? require 'ipaddr' ip_prospect = IPAddr.new(prospective_ip_address) ip_addresses.each do |ip_address| ip_range = (ip_address.match(/[\-\*]/)) ? (ip_address.match(/\-/)) ? (IPAddr.new(ip_address.split("-")[0])..IPAddr.new(ip_address.split("-")[1])) : (ip_address.gsub(/\*/, "0")..ip_address.gsub(/\*/, "255")) : IPAddr.new(ip_address).to_range return true if ip_range === ip_prospect unless ip_range.nil? end return false; end |
#instantiate_services! ⇒ Object
Instantiates a new copy of all services included in this institution, returns an array.
16 17 18 |
# File 'lib/authpds/institution.rb', line 16 def instantiate_services! services.collect {|s| } end |
#to_h ⇒ Object
36 37 38 39 40 |
# File 'lib/authpds/institution.rb', line 36 def to_h h = {} members.each {|m| h[m.to_sym] = self.send(m)} h end |