simple_response 0.9.0 → 0.10.0
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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/simple_response/response.rb +2 -3
- data/lib/simple_response/simple_struct.rb +10 -6
- data/lib/simple_response/version.rb +1 -1
- data/lib/simple_response.rb +1 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13876aa28d3ca6144893bb11b5c1bf3e85b9b0d2ef6491dd03d7279643349aae
|
4
|
+
data.tar.gz: 4f38843421372ef7c349298c84ef5c84c3099fafc59b5e1e1d497bbc76e7a6ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7abf84566c51a0e6961649796d27797856af8ef5495c09b0d4cef3c015d4e286ab8fa4ead1f44acb76e841a3d1f98a6c4932caf95f5ce9ad693ca325c9c09f1
|
7
|
+
data.tar.gz: cd236e89b8d3678b1141322af46f31451d68d7add77cde5530cda50d9b13b11e58391fba65ebeae15011c98fea1d45c89dd1347ac20294d9d2c5c64ad058fc9d
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
module SimpleResponse
|
2
|
-
require 'ostruct'
|
3
2
|
require 'simple_response/query_methods'
|
4
3
|
require 'simple_response/simple_struct'
|
5
4
|
|
6
5
|
class Response < SimpleStruct
|
7
|
-
def initialize(success
|
8
|
-
super
|
6
|
+
def initialize(success:, **attributes)
|
7
|
+
super(attributes)
|
9
8
|
@success = success
|
10
9
|
end
|
11
10
|
|
@@ -1,11 +1,19 @@
|
|
1
1
|
module SimpleResponse
|
2
|
+
# SimpleStruct class is an OpenStruct-like class that allows
|
3
|
+
# to assign and read arbitrary values.
|
2
4
|
class SimpleStruct
|
3
5
|
include SimpleResponse::QueryMethods
|
4
6
|
|
5
|
-
def initialize(
|
6
|
-
@attributes =
|
7
|
+
def initialize(**args)
|
8
|
+
@attributes = args.dup
|
7
9
|
end
|
8
10
|
|
11
|
+
def keys
|
12
|
+
@attributes.keys
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
9
17
|
def method_missing(name, *args, &block)
|
10
18
|
if existing_query_method?(name)
|
11
19
|
query_method(name)
|
@@ -27,9 +35,5 @@ module SimpleResponse
|
|
27
35
|
def write_method?(name)
|
28
36
|
name[-1] == '='
|
29
37
|
end
|
30
|
-
|
31
|
-
def keys
|
32
|
-
@attributes.keys
|
33
|
-
end
|
34
38
|
end
|
35
39
|
end
|
data/lib/simple_response.rb
CHANGED
@@ -3,9 +3,7 @@ require "simple_response/response"
|
|
3
3
|
|
4
4
|
module SimpleResponse
|
5
5
|
def self.new(success: true, **attributes)
|
6
|
-
SimpleResponse::Response.new(success: success)
|
7
|
-
attributes.each { |k, v| response.send("#{k}=", v) }
|
8
|
-
end
|
6
|
+
SimpleResponse::Response.new(success: success, **attributes)
|
9
7
|
end
|
10
8
|
|
11
9
|
def self.success(attributes = {})
|