Class: RubyMVC::ActionGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_mvc/controllers/action_group.rb

Overview

This class provides a collection for actions so that they can be more easily managed. ActionGroups form the basis for creating menus, toolbars and similar control groups.

Instance Method Summary collapse

Constructor Details

#initializeActionGroup

Returns a new instance of ActionGroup.



33
34
35
36
# File 'lib/ruby_mvc/controllers/action_group.rb', line 33

def initialize
  @actions = []
  @index = {}
end

Instance Method Details

#<<(action) ⇒ Object



44
45
46
47
48
49
# File 'lib/ruby_mvc/controllers/action_group.rb', line 44

def <<(action)
  if !@actions.include? action
    @actions << action
    @index[action.key] = action
  end
end

#[](key) ⇒ Object

This method is used to retrieve an action by action key.



40
41
42
# File 'lib/ruby_mvc/controllers/action_group.rb', line 40

def [](key)
  @index[key]
end

#delete(action) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/ruby_mvc/controllers/action_group.rb', line 51

def delete(action)
  if action.is_a? Symbol
    key = action
  else
    key = action.key
  end
  val = @index.delete(key)
  @actions.delete(val)
end

#each(&block) ⇒ Object



61
62
63
# File 'lib/ruby_mvc/controllers/action_group.rb', line 61

def each(&block)
  @actions.each(&block)
end

#each_with_index(&block) ⇒ Object



65
66
67
# File 'lib/ruby_mvc/controllers/action_group.rb', line 65

def each_with_index(&block)
  @actions.each_with_index(&block)
end