shaf_client 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/shaf_client.rb +1 -1
- data/lib/shaf_client/form.rb +2 -0
- data/lib/shaf_client/resource.rb +27 -3
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fdd37c57d1bf069216445f7aacbb04e50aa451bd91a0512f21733aa22b030d2
|
4
|
+
data.tar.gz: 423457d2aa3cd2d79c959488f70ba9a4f454b5a2ce8887fc34377d7613223b0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77716b275f965a5f9ae1c5753497bcd5590d5e1250cd0b4241783f8bb874597b42a4ed840ad32d9945313cd64a9366294b015b7825b15aaa208aba8430e8232e
|
7
|
+
data.tar.gz: a110d1773f71aa7d4d71aa04cc702e26a462df87116bd29339c5fbd60d3af001992a968493bbaeaecd5fc731931cc25ede2e2ae72f7da9bde867d3a60a307a66
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/shaf_client.rb
CHANGED
data/lib/shaf_client/form.rb
CHANGED
data/lib/shaf_client/resource.rb
CHANGED
@@ -5,7 +5,32 @@ class ShafClient
|
|
5
5
|
class Resource < BaseResource
|
6
6
|
attr_reader :http_status, :headers
|
7
7
|
|
8
|
-
|
8
|
+
class ResourceClasses
|
9
|
+
class << self
|
10
|
+
def all
|
11
|
+
@all ||= Hash.new(Resource)
|
12
|
+
end
|
13
|
+
|
14
|
+
def for(name)
|
15
|
+
all[name]
|
16
|
+
end
|
17
|
+
|
18
|
+
def set(name, clazz)
|
19
|
+
all[name] = clazz
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.profile(name)
|
25
|
+
ResourceClasses.set(name, self)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.build(client, payload, status = nil, headers = {})
|
29
|
+
profile = headers.fetch('content-type', '')[/profile=([\w-]+)/, 1]
|
30
|
+
ResourceClasses.for(profile).new(client, payload, status, headers)
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(client, payload, status = nil, headers = {})
|
9
34
|
@client = client
|
10
35
|
@http_status = status
|
11
36
|
@headers = headers
|
@@ -15,8 +40,7 @@ class ShafClient
|
|
15
40
|
%i[get put post delete patch get_form].each do |method|
|
16
41
|
define_method(method) do |rel, payload = nil, **options|
|
17
42
|
href = link(rel).href
|
18
|
-
|
19
|
-
client.send(*args, payload: payload, **options)
|
43
|
+
client.send(method, href, payload: payload, **options)
|
20
44
|
end
|
21
45
|
end
|
22
46
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shaf_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sammy Henningsson
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
ZMhjYR7sRczGJx+GxGU2EaR0bjRsPVlC4ywtFxoOfRG3WaJcpWGEoAoMJX6Z0bRv
|
31
31
|
M40=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2019-
|
33
|
+
date: 2019-03-25 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: faraday
|
metadata.gz.sig
CHANGED
Binary file
|