signaling 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca19fc3b658bd738c01325701134017ced13e62c
4
- data.tar.gz: 8085032158fb6309eb198105fae4d8610b5b9f07
3
+ metadata.gz: 7d14361be16dd1b4ac9b0bc4fd47b0047f5ea65e
4
+ data.tar.gz: 30251856a6de2d3c88a13e20cb4cd51c0571c592
5
5
  SHA512:
6
- metadata.gz: 4f0242e051f363d0c4547d821b0774fccd073eb1856651881bd136e428d279c326a7aa0568341e8cbaee0ffde3d2761abcbe9192839636f15b268798999775a4
7
- data.tar.gz: 76a065116c5c79a40b6468330ec4195b0513eb7beb31f2f9a87a8af9b4d10e5210f43bb973a3ced442127470b31f9aa004682fc75dd9ef70c64f54d4ba251dac
6
+ metadata.gz: ad3998edffe0846b29c69d8f2a5773701eacdb5ce55866f37bdd61db6106e5619e21cdd9190aae6e8fad0a9defab000ba8c86088e640c542d9e14f2e2ce6de76
7
+ data.tar.gz: f2be136ba6a2d370c19a1e73371fef7c479f013d566434df899ae439065aa9805cb344717363b0d4804beb71c9c2df241090b5700ce39b02a8b132388d44790b
data/README.md CHANGED
@@ -151,6 +151,25 @@ Then signaling will load these errors to the `ItemList` models
151
151
  This file serves as a reference implementation for a controller and as a guide
152
152
  to make sure Signaling follows it's main goal.
153
153
 
154
+
155
+ ### Custom action paths
156
+
157
+ To change the URL of a specific action:
158
+
159
+ module ExampleCom
160
+ class ItemList < Signaling::Base
161
+ use_api ExampleCom::Api
162
+
163
+ define_action :index, method: :get, path: 'accounts/:account_id/item_lists.json'
164
+ end
165
+ end
166
+
167
+ Then you can use:
168
+
169
+ > lists = ExampleCom::ItemList.all(account_id: '123')
170
+ # GET /accounts/123/item_lists.json
171
+
172
+
154
173
  ## Contributing
155
174
 
156
175
  1. Fork it
@@ -28,11 +28,12 @@ module Signaling::Base::Http
28
28
  end
29
29
 
30
30
  def define_action(action_name, options)
31
- self._defined_actions ||= {}
32
31
  unless options[:method] && options[:path]
33
32
  raise ArgumentError, ':method and :path options are required'
34
33
  end
35
- self._defined_actions[action_name.to_sym] = options
34
+
35
+ actions = self._defined_actions || {}
36
+ self._defined_actions = actions.merge(action_name.to_sym => options)
36
37
  end
37
38
 
38
39
  # convert value to params-friendly hash/array
@@ -1,3 +1,3 @@
1
1
  module Signaling
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe "README features" do
4
+ describe "Custom actions" do
5
+ let(:custom_path) { 'accounts/:account_id/item_lists.json' }
6
+
7
+ around do |example|
8
+ begin
9
+ ExampleCom::ItemList.define_action :index, method: :get, path: custom_path
10
+ example.run
11
+ ensure
12
+ ExampleCom::ItemList.define_action :index, method: :get, path: ':route_key.json'
13
+ end
14
+ end
15
+
16
+ before do
17
+ stub_request(:get, expected_item_lists_path)
18
+ end
19
+
20
+ specify "will change the URL for the request" do
21
+ ExampleCom::ItemList.all(account_id: '123')
22
+ expect_request(:get, path: expected_item_lists_path)
23
+ end
24
+
25
+ specify "are isolated to class" do
26
+ expect(ExampleCom::Item._defined_actions[:index][:path]).to eq(':route_key.json')
27
+ end
28
+
29
+ def expected_item_lists_path
30
+ example_com_build_url('accounts/123/item_lists.json')
31
+ end
32
+
33
+ end
34
+ end
35
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: signaling
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neer Friedman
@@ -207,6 +207,7 @@ files:
207
207
  - spec/integration/readme_features/api_setup_spec.rb
208
208
  - spec/integration/readme_features/attributes_spec.rb
209
209
  - spec/integration/readme_features/controller_usage_spec.rb
210
+ - spec/integration/readme_features/custom_action_path_spec.rb
210
211
  - spec/integration/readme_features/errors_spec.rb
211
212
  - spec/integration/readme_features/nested_models_spec.rb
212
213
  - spec/spec_helper.rb
@@ -244,6 +245,7 @@ test_files:
244
245
  - spec/integration/readme_features/api_setup_spec.rb
245
246
  - spec/integration/readme_features/attributes_spec.rb
246
247
  - spec/integration/readme_features/controller_usage_spec.rb
248
+ - spec/integration/readme_features/custom_action_path_spec.rb
247
249
  - spec/integration/readme_features/errors_spec.rb
248
250
  - spec/integration/readme_features/nested_models_spec.rb
249
251
  - spec/spec_helper.rb