Class: Puavo::Organisation
- Inherits:
-
Object
- Object
- Puavo::Organisation
show all
- Defined in:
- lib/puavo/organisation.rb
Constant Summary
collapse
- @@configurations =
YAML.load_file("#{RAILS_ROOT}/config/organisations.yml")
- @@key_by_host =
{}
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/puavo/organisation.rb', line 28
def method_missing(method, *args)
if @@configurations[organisation_key].has_key?(method.to_s)
@@configurations[organisation_key][method.to_s]
else
super
end
end
|
Instance Attribute Details
#organisation_key ⇒ Object
Returns the value of attribute organisation_key.
13
14
15
|
# File 'lib/puavo/organisation.rb', line 13
def organisation_key
@organisation_key
end
|
Class Method Details
.all ⇒ Object
63
64
65
|
# File 'lib/puavo/organisation.rb', line 63
def all
@@configurations
end
|
.find(key) ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/puavo/organisation.rb', line 37
def find(key)
if self.configurations.has_key?(key)
organisation = Organisation.new
organisation.organisation_key = key
organisation
else
logger.info "Can not find configuration key: #{key}"
false
end
end
|
.find_by_host(host) ⇒ Object
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/puavo/organisation.rb', line 52
def find_by_host(host)
if @@key_by_host.has_key?(host)
organisation = Organisation.new
organisation.organisation_key = @@key_by_host[host]
organisation
else
logger.info "Can not find organisation by host: #{host}"
false
end
end
|
.key_by_host(host) ⇒ Object
48
49
50
|
# File 'lib/puavo/organisation.rb', line 48
def key_by_host(host)
@@key_by_host[host]
end
|
.logger ⇒ Object
67
68
69
|
# File 'lib/puavo/organisation.rb', line 67
def logger
RAILS_DEFAULT_LOGGER
end
|
Instance Method Details
#locale ⇒ Object
16
17
18
|
# File 'lib/puavo/organisation.rb', line 16
def locale
@@configurations[organisation_key]["locale"] || :en
end
|
#schools(user) ⇒ Object
20
21
22
|
# File 'lib/puavo/organisation.rb', line 20
def schools(user)
School.all_with_permissions user
end
|
#value_by_key(key) ⇒ Object
24
25
26
|
# File 'lib/puavo/organisation.rb', line 24
def value_by_key(key)
@@configurations[organisation_key][key]
end
|