Class: LibraryGroup

Inherits:
ApplicationRecord
  • Object
show all
Includes:
MasterModel
Defined in:
app/models/library_group.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#delete_header_logoObject

Returns the value of attribute delete_header_logo.



40
41
42
# File 'app/models/library_group.rb', line 40

def 
  @delete_header_logo
end

Class Method Details

.site_configObject



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

Returns:

  • (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

Returns:

  • (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, options = {})
  options = { network_type: :lan }.merge(options)
  client_ip = IPAddr.new(ip_address)
  case options[: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_librariesObject



54
55
56
# File 'app/models/library_group.rb', line 54

def real_libraries
  libraries.where.not(name: 'web')
end