Class: HaveAPI::Fs::Components::ResourceDir
Constant Summary
Constants included
from Help
Help::SEARCH_PATH
Instance Attribute Summary collapse
#atime, #context, #ctime, #mtime
Instance Method Summary
collapse
Methods inherited from Directory
#directory?
Methods included from Help
find!, included
#abspath, #bound=, #bound?, children_reader, component, #directory?, #executable?, #file?, #find, inherited, #invalid?, #invalidate, #parent, #path, #readable?, #reset, #times, #unsaved?, #use, #writable?
Constructor Details
#initialize(resource) ⇒ ResourceDir
Returns a new instance of ResourceDir.
6
7
8
9
|
# File 'lib/haveapi/fs/components/resource_dir.rb', line 6
def initialize(resource)
super()
@resource = resource
end
|
Instance Attribute Details
#resource ⇒ Object
Returns the value of attribute resource.
4
5
6
|
# File 'lib/haveapi/fs/components/resource_dir.rb', line 4
def resource
@resource
end
|
Instance Method Details
#contents ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/haveapi/fs/components/resource_dir.rb', line 17
def contents
load_contents if @index && (!@data || @refresh)
ret = super + %w(actions) + subresources.map(&:to_s)
ret.concat(@data.map { |v| v.id.to_s }) if @data
ret << 'create.yml' if find(:actions).find(:create)
if @index
ret.concat(@index.action.input_params.keys.map { |v| "by-#{v}" })
end
ret
end
|
#delete(id) ⇒ Object
35
36
37
38
39
|
# File 'lib/haveapi/fs/components/resource_dir.rb', line 35
def delete(id)
return unless @data
i = @data.index { |v| v.id == id }
@data.delete_at(i) if i
end
|
#refresh ⇒ Object
31
32
33
|
# File 'lib/haveapi/fs/components/resource_dir.rb', line 31
def refresh
@refresh = true
end
|
#setup ⇒ Object
11
12
13
14
15
|
# File 'lib/haveapi/fs/components/resource_dir.rb', line 11
def setup
super
@index = use(:actions, :index)
@data = nil
end
|
#title ⇒ Object
41
42
43
|
# File 'lib/haveapi/fs/components/resource_dir.rb', line 41
def title
"Resource #{@resource._name.to_s.capitalize}"
end
|