2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/file_system_resource.rb', line 2
def self.included(klass)
klass.class_eval do
def content
if file_system_resource?
File.read(path)
else
self[:content]
end
end
def name
file_system_resource? ? self[:name] + '_fs' : self[:name]
end
def path
RAILS_ROOT + "/radiant/#{self.class.name.downcase.pluralize}/#{filename}.radius"
end
def content=(value)
raise "File System Resources are read-only from the admin." if file_system_resource?
self[:content] = value
end
def filename
raise "#filename should not be called unless a file_system_resource." unless file_system_resource?
self[:content]
end
def filename=(value)
self[:content] = value
end
end
end
|