Class: ActiveScaffold::DataStructures::ActionLinks
- Includes:
- Enumerable
- Defined in:
- lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_links.rb
Instance Method Summary collapse
-
#[](val) ⇒ Object
finds an ActionLink by matching the action.
-
#add(action, options = {}) ⇒ Object
(also: #<<)
adds an ActionLink, creating one from the arguments if need be.
- #delete(val) ⇒ Object
-
#each(type = nil) ⇒ Object
iterates over the links, possibly by type.
- #empty? ⇒ Boolean
-
#initialize ⇒ ActionLinks
constructor
A new instance of ActionLinks.
Constructor Details
#initialize ⇒ ActionLinks
Returns a new instance of ActionLinks.
5 6 7 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_links.rb', line 5 def initialize @set = [] end |
Instance Method Details
#[](val) ⇒ Object
finds an ActionLink by matching the action
18 19 20 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_links.rb', line 18 def [](val) @set.find {|item| item.action == val.to_s} end |
#add(action, options = {}) ⇒ Object Also known as: <<
adds an ActionLink, creating one from the arguments if need be
10 11 12 13 14 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_links.rb', line 10 def add(action, = {}) link = action.is_a?(ActiveScaffold::DataStructures::ActionLink) ? action : ActiveScaffold::DataStructures::ActionLink.new(action, ) # NOTE: this duplicate check should be done by defining the comparison operator for an Action data structure @set << link unless @set.any? {|a| a.action == link.action and a.controller == link.controller and a.parameters == link.parameters} end |
#delete(val) ⇒ Object
22 23 24 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_links.rb', line 22 def delete(val) @set.delete_if{|item| item.action == val.to_s} end |
#each(type = nil) ⇒ Object
iterates over the links, possibly by type
27 28 29 30 31 32 33 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_links.rb', line 27 def each(type = nil) type = type.to_sym if type @set.each {|item| next if type and item.type != type yield item } end |
#empty? ⇒ Boolean
35 36 37 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_links.rb', line 35 def empty? @set.size == 0 end |