Class: HaveAPI::Fs::Components::ResourceActionDir

Inherits:
Directory show all
Defined in:
lib/haveapi/fs/components/resource_action_dir.rb

Constant Summary

Constants included from Help

Help::SEARCH_PATH

Instance Attribute Summary collapse

Attributes inherited from HaveAPI::Fs::Component

#atime, #context, #ctime, #mtime

Instance Method Summary collapse

Methods inherited from Directory

#directory?

Methods included from Help

find!, included

Methods inherited from HaveAPI::Fs::Component

#abspath, #bound=, #bound?, children_reader, component, #directory?, #executable?, #file?, #find, inherited, #invalid?, #invalidate, #parent, #path, #readable?, #reset, #setup, #times, #unsaved?, #use, #writable?

Constructor Details

#initialize(r) ⇒ ResourceActionDir

Returns a new instance of ResourceActionDir.



6
7
8
9
10
11
# File 'lib/haveapi/fs/components/resource_action_dir.rb', line 6

def initialize(r)
  @resource = r
  @instance = r.is_a?(HaveAPI::Client::ResourceInstance) || r.is_a?(HaveAPI::Fs::HashWrapper)

  super()
end

Instance Attribute Details

#resourceObject (readonly)

Returns the value of attribute resource.



4
5
6
# File 'lib/haveapi/fs/components/resource_action_dir.rb', line 4

def resource
  @resource
end

Instance Method Details

#contentsObject



13
14
15
# File 'lib/haveapi/fs/components/resource_action_dir.rb', line 13

def contents
  super + relevant_actions.map(&:to_s)
end

#instance?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/haveapi/fs/components/resource_action_dir.rb', line 37

def instance?
  @instance
end

#relevant_actionsObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/haveapi/fs/components/resource_action_dir.rb', line 17

def relevant_actions
  return @actions if @actions
  @actions = []

  @resource.actions.each do |name, a|
    pos = a.url.index(":#{@resource._name}_id")

    if @instance
      cond = pos

    else
      cond = pos.nil?
    end

    @actions << name if cond
  end

  @actions
end

#titleObject



41
42
43
# File 'lib/haveapi/fs/components/resource_action_dir.rb', line 41

def title
  'Actions'
end