Class: HaveAPI::Fs::Components::ResourceInstanceDir
Constant Summary
Constants included
from Help
Help::SEARCH_PATH
Instance Attribute Summary
Attributes inherited from ResourceDir
#resource
#atime, #context, #ctime, #mtime
Instance Method Summary
collapse
Methods inherited from ResourceDir
#delete, #initialize, #refresh
Methods inherited from Directory
#directory?
Methods included from Help
find!, included
#abspath, #bound=, #bound?, children_reader, component, #directory?, #executable?, #file?, #find, inherited, #initialize, #invalid?, #invalidate, #parent, #path, #readable?, #reset, #times, #unsaved?, #use, #writable?
Instance Method Details
#attributes ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/haveapi/fs/components/resource_instance_dir.rb', line 63
def attributes
ret = []
params = @resource.actions[:show].params
@resource.attributes.each do |k, v|
next if k == :_meta
if params[k][:type] == 'Resource'
ret << "#{k}_id"
ret << k.to_s if v
else
ret << k.to_s
end
end
ret
end
|
#contents ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/haveapi/fs/components/resource_instance_dir.rb', line 16
def contents
ret = super - %w(create.yml)
ret.concat(attributes)
ret.concat(%w(save edit.yml)) if @update
ret << 'meta'
ret
end
|
#replace_association(name, id) ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/haveapi/fs/components/resource_instance_dir.rb', line 30
def replace_association(name, id)
return unless children.has_key?(name)
children[name].invalidate
context.cache.drop_below(path)
@resource.send("#{name}_id=", id)
children[name] = [ResourceInstanceDir, @resource.send(name)]
end
|
#save ⇒ Object
24
25
26
27
28
|
# File 'lib/haveapi/fs/components/resource_instance_dir.rb', line 24
def save
ret = @update.exec
self.mtime = Time.now
ret
end
|
#setup ⇒ Object
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/haveapi/fs/components/resource_instance_dir.rb', line 5
def setup
super
@show = use(:actions, :show)
@update = use(:actions, :update)
children[:save] = [SaveInstance, self, bound: true] if @update
@index = false
end
|
#subresources ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/haveapi/fs/components/resource_instance_dir.rb', line 47
def subresources
return @subresources if @subresources
@subresources = []
@resource.resources.each do |r_name, r|
r.actions.each do |a_name, a|
if a.url.index(":#{@resource._name}_id")
@subresources << r_name
break
end
end
end
@subresources
end
|
#title ⇒ Object
82
83
84
|
# File 'lib/haveapi/fs/components/resource_instance_dir.rb', line 82
def title
"#{@resource._name.to_s.capitalize} ##{@resource.id}"
end
|
#update_association(name) ⇒ Object
40
41
42
43
44
45
|
# File 'lib/haveapi/fs/components/resource_instance_dir.rb', line 40
def update_association(name)
children[name].invalidate
context.cache.drop_below(path)
children[name] = [ResourceInstanceDir, @resource.send(name)]
end
|