Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

Commit

Permalink
add some helper methods to handle deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Francl committed Sep 23, 2013
1 parent 4c3ed3f commit 08822cb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/swiftype.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@

module Swiftype
extend Swiftype::Configuration

def self.const_missing(const_name)
super unless const_name == :Easy
warn "`Swiftype::Easy` has been deprecated. Use `Swiftype::Client` instead."
Client
end
end

5 changes: 5 additions & 0 deletions lib/swiftype/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ module Swiftype
class Client
include Swiftype::Request

def self.configure(&block)
warn "`Swiftype::Easy.configure` has been deprecated. Use `Swiftype.configure` instead."
Swiftype.configure &block
end

# Create a new Swiftype::Client client
#
# @param options [Hash] a hash of configuration options that will overrided what is set on the Swiftype class.
Expand Down
20 changes: 20 additions & 0 deletions spec/deprecated_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'spec_helper'

describe 'deprecated classes and methods' do
context 'Swiftype::Easy' do
it 'returns Swiftype::Client' do
Swiftype::Easy.should == Swiftype::Client
end
end

context 'Swiftype::Easy.configure' do
it 'calls warn and calls Swiftype.configure' do
Swiftype::Client.should_receive(:warn)
Swiftype::Easy.configure do |config|
config.api_key = 'got set'
end

Swiftype.api_key.should == 'got set'
end
end
end

0 comments on commit 08822cb

Please sign in to comment.