Class: LibraryGroup
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- LibraryGroup
- Includes:
- MasterModel
- Defined in:
- app/models/library_group.rb
Instance Attribute Summary collapse
-
#delete_header_logo ⇒ Object
Returns the value of attribute delete_header_logo.
Class Method Summary collapse
Instance Method Summary collapse
- #config? ⇒ Boolean
- #network_access_allowed?(ip_address, options = {}) ⇒ Boolean
- #real_libraries ⇒ Object
Instance Attribute Details
#delete_header_logo ⇒ Object
Returns the value of attribute delete_header_logo.
40 41 42 |
# File 'app/models/library_group.rb', line 40 def delete_header_logo @delete_header_logo end |
Class Method Details
.site_config ⇒ Object
42 43 44 |
# File 'app/models/library_group.rb', line 42 def self.site_config LibraryGroup.order(:created_at).first end |
.system_name(locale = I18n.locale) ⇒ Object
46 47 48 |
# File 'app/models/library_group.rb', line 46 def self.system_name(locale = I18n.locale) LibraryGroup.site_config.display_name.localize(locale) end |
Instance Method Details
#config? ⇒ Boolean
50 51 52 |
# File 'app/models/library_group.rb', line 50 def config? true if self == LibraryGroup.site_config end |
#network_access_allowed?(ip_address, options = {}) ⇒ Boolean
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/models/library_group.rb', line 58 def network_access_allowed?(ip_address, = {}) = { network_type: :lan }.merge() client_ip = IPAddr.new(ip_address) case [:network_type] when :admin allowed_networks = admin_networks.to_s.split else allowed_networks = my_networks.to_s.split end allowed_networks.each do |allowed_network| begin network = IPAddr.new(allowed_network) return true if network.include?(client_ip) rescue ArgumentError nil end end return false end |
#real_libraries ⇒ Object
54 55 56 |
# File 'app/models/library_group.rb', line 54 def real_libraries libraries.where.not(name: 'web') end |