Skip to content

Commit

Permalink
Simplify iteration where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
snusnu committed Jul 29, 2013
1 parent ea9f2ff commit 742e4d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions lib/substation/chain/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ class Definition
# @api private
def initialize(processors = [])
@processors = []
processors.each { |processor| self << processor }
processors.each(&method(:<<))
end

# An empty instance
EMPTY = new(EMPTY_ARRAY).freeze

# Append +processor+ to {#processors}
#
# @param [#call] processor
Expand All @@ -50,6 +47,11 @@ def <<(processor)
self
end

# The following const MUST have #initialize and #<< defined already

# An empty instance
EMPTY = new(EMPTY_ARRAY).freeze

# Replace the failure chain of the processor identified by +name+
#
# @param [Symbol] name
Expand Down
2 changes: 1 addition & 1 deletion lib/substation/chain/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def use(processor)
#
# @api private
def chain(processors)
processors.each { |processor| use(processor) }
processors.each(&method(:use))
self
end

Expand Down

0 comments on commit 742e4d6

Please sign in to comment.