signaling 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -0
- data/lib/signaling/base/http.rb +3 -2
- data/lib/signaling/version.rb +1 -1
- data/spec/integration/readme_features/custom_action_path_spec.rb +35 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d14361be16dd1b4ac9b0bc4fd47b0047f5ea65e
|
4
|
+
data.tar.gz: 30251856a6de2d3c88a13e20cb4cd51c0571c592
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/signaling/base/http.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/signaling/version.rb
CHANGED
@@ -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.
|
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
|