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

Commit 08822cb

Browse files
author
Luke Francl
committed
add some helper methods to handle deprecation
1 parent 4c3ed3f commit 08822cb

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

lib/swiftype.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,11 @@
22

33
module Swiftype
44
extend Swiftype::Configuration
5+
6+
def self.const_missing(const_name)
7+
super unless const_name == :Easy
8+
warn "`Swiftype::Easy` has been deprecated. Use `Swiftype::Client` instead."
9+
Client
10+
end
511
end
612

lib/swiftype/client.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ module Swiftype
77
class Client
88
include Swiftype::Request
99

10+
def self.configure(&block)
11+
warn "`Swiftype::Easy.configure` has been deprecated. Use `Swiftype.configure` instead."
12+
Swiftype.configure &block
13+
end
14+
1015
# Create a new Swiftype::Client client
1116
#
1217
# @param options [Hash] a hash of configuration options that will overrided what is set on the Swiftype class.

spec/deprecated_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
require 'spec_helper'
2+
3+
describe 'deprecated classes and methods' do
4+
context 'Swiftype::Easy' do
5+
it 'returns Swiftype::Client' do
6+
Swiftype::Easy.should == Swiftype::Client
7+
end
8+
end
9+
10+
context 'Swiftype::Easy.configure' do
11+
it 'calls warn and calls Swiftype.configure' do
12+
Swiftype::Client.should_receive(:warn)
13+
Swiftype::Easy.configure do |config|
14+
config.api_key = 'got set'
15+
end
16+
17+
Swiftype.api_key.should == 'got set'
18+
end
19+
end
20+
end

0 commit comments

Comments
 (0)