Class: Pakyow::Support::Pipeline::Internal Private
- Inherits:
-
Object
- Object
- Pakyow::Support::Pipeline::Internal
- Defined in:
- lib/pakyow/support/pipeline.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #actions ⇒ Object readonly private
Instance Method Summary collapse
- #action(target, *options, before: nil, after: nil, &block) ⇒ Object private
- #callable(context) ⇒ Object private
- #exclude_actions(actions) ⇒ Object private
- #include_actions(actions) ⇒ Object private
-
#initialize(&block) ⇒ Internal
constructor
private
A new instance of Internal.
- #initialize_copy(_) ⇒ Object private
- #skip(*actions) ⇒ Object private
Constructor Details
#initialize(&block) ⇒ Internal
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Internal.
186 187 188 189 190 191 192 |
# File 'lib/pakyow/support/pipeline.rb', line 186 def initialize(&block) @actions = [] if block_given? instance_exec(&block) end end |
Instance Attribute Details
#actions ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
184 185 186 |
# File 'lib/pakyow/support/pipeline.rb', line 184 def actions @actions end |
Instance Method Details
#action(target, *options, before: nil, after: nil, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/pakyow/support/pipeline.rb', line 203 def action(target, *, before: nil, after: nil, &block) Action.new(target, *, &block).tap do |action| if before if i = @actions.index { |a| a.name == before } @actions.insert(i, action) else @actions.unshift(action) end elsif after if i = @actions.index { |a| a.name == after } @actions.insert(i + 1, action) else @actions << action end else @actions << action end end end |
#callable(context) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
199 200 201 |
# File 'lib/pakyow/support/pipeline.rb', line 199 def callable(context) Callable.new(@actions, context) end |
#exclude_actions(actions) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/pakyow/support/pipeline.rb', line 233 def exclude_actions(actions) # Map input into a common denominator, to exclude both names and other action objects. targets = actions.map { |action| if action.is_a?(Action) action.target else action end } @actions.delete_if { |action| targets.include?(action.target) } end |
#include_actions(actions) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
229 230 231 |
# File 'lib/pakyow/support/pipeline.rb', line 229 def include_actions(actions) @actions.concat(actions).uniq! end |
#initialize_copy(_) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
194 195 196 197 |
# File 'lib/pakyow/support/pipeline.rb', line 194 def initialize_copy(_) @actions = @actions.dup super end |
#skip(*actions) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
223 224 225 226 227 |
# File 'lib/pakyow/support/pipeline.rb', line 223 def skip(*actions) @actions.delete_if { |action| actions.include?(action.name) } end |