Skip to content

Commit

Permalink
Introduce EMPTY_ARRAY and use it where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
snusnu committed Jul 4, 2013
1 parent 933098e commit 43df9e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/substation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
# action.

module Substation

# An empty frozen array useful for (default) parameters
EMPTY_ARRAY = [].freeze

end

require 'substation/utils'
Expand Down
2 changes: 1 addition & 1 deletion lib/substation/chain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Chain
include Adamantium::Flat

# Empty chain
EMPTY = Class.new(self).new([])
EMPTY = Class.new(self).new(EMPTY_ARRAY)

# Call the chain
#
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 @@ -129,7 +129,7 @@ def self.build(*blocks)
#
# @api private
def self.coerce(*blocks)
blocks.compact.inject(new(Chain::EMPTY)) { |dsl, block|
blocks.compact.inject(new(EMPTY_ARRAY)) { |dsl, block|
dsl.instance_eval(&block)
}
end
Expand Down

0 comments on commit 43df9e9

Please sign in to comment.