Skip to content

Commit

Permalink
add Plek.current alias to ease migration
Browse files Browse the repository at this point in the history
  • Loading branch information
philandstuff committed Nov 26, 2012
1 parent 19fbd18 commit 309ef59
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/plek.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,12 @@ def name_for(service)
name.gsub!(/[^a-z\.-]+/, '')
name
end

class << self
# This alias allows calls to be made in the old style:
# Plek.current.find('foo')
# as well as the new style:
# Plek.new.find('foo')
alias_method :current, :new
end
end
3 changes: 3 additions & 0 deletions test/plek_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,7 @@ def test_should_return_dash_divided_source_in_production
assert_equal "https://explore-reviewomatic.production.alphagov.co.uk", url
end

def test_should_be_able_to_use_current_for_old_style_calls
assert_equal Plek.new.find("foo"), Plek.current.find("foo")
end
end

0 comments on commit 309ef59

Please sign in to comment.