Class: Clowne::Adapters::Registry
- Inherits:
-
Object
- Object
- Clowne::Adapters::Registry
- Defined in:
- lib/clowne/adapters/registry.rb
Overview
:nodoc: all
Defined Under Namespace
Modules: Container
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#mapping ⇒ Object
readonly
Returns the value of attribute mapping.
Instance Method Summary collapse
- #append(action) ⇒ Object
- #dup ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #insert_after(after, action) ⇒ Object
- #insert_before(before, action) ⇒ Object
- #unshift(action) ⇒ Object
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
57 58 59 60 |
# File 'lib/clowne/adapters/registry.rb', line 57 def initialize @actions = [] @mapping = {} end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
55 56 57 |
# File 'lib/clowne/adapters/registry.rb', line 55 def actions @actions end |
#mapping ⇒ Object
Returns the value of attribute mapping.
55 56 57 |
# File 'lib/clowne/adapters/registry.rb', line 55 def mapping @mapping end |
Instance Method Details
#append(action) ⇒ Object
82 83 84 85 |
# File 'lib/clowne/adapters/registry.rb', line 82 def append(action) actions.delete(action) actions.push action end |
#dup ⇒ Object
92 93 94 95 96 97 |
# File 'lib/clowne/adapters/registry.rb', line 92 def dup self.class.new.tap do |duped| actions.each { |act| duped.append(act) } duped.mapping = mapping.dup end end |
#insert_after(after, action) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/clowne/adapters/registry.rb', line 62 def insert_after(after, action) actions.delete(action) after_index = actions.find_index(after) raise "Plan action not found: #{after}" if after_index.nil? actions.insert(after_index + 1, action) end |
#insert_before(before, action) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/clowne/adapters/registry.rb', line 72 def insert_before(before, action) actions.delete(action) before_index = actions.find_index(before) raise "Plan action not found: #{before}" if before_index.nil? actions.insert(before_index, action) end |
#unshift(action) ⇒ Object
87 88 89 90 |
# File 'lib/clowne/adapters/registry.rb', line 87 def unshift(action) actions.delete(action) actions.unshift action end |