gifter_hub 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gifter_hub/api_resource.rb +10 -16
- data/lib/gifter_hub/errors/api_connection_error.rb +1 -1
- data/lib/gifter_hub/errors/api_error.rb +1 -1
- data/lib/gifter_hub/errors/{bamboo_error.rb → gifter_hub_error.rb} +1 -1
- data/lib/gifter_hub/gift_card.rb +0 -2
- data/lib/gifter_hub/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ca2b5ca79d45d5fe435e9881d3e61455e37dfa2
|
4
|
+
data.tar.gz: ea8159d053556f2efeeac4f18b1f8d74e9a5f9d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4c9f100d64c19f7ca7a50aff27ef3d886276e98b840603b22eb6368b769f367a8a50331f8f44bd4dca065a823d5fd4c56e3d9adc060537c6d90c341d795c4fc
|
7
|
+
data.tar.gz: 2f15e10f5d09134dd70e5f8c0c20af1aff1377b3747a1354f12374a84387434e72d625095a439eaa83b7e1c5bd64eb93db93e6a4fad62a0f1fa7a085017c2798
|
@@ -1,12 +1,13 @@
|
|
1
1
|
module GifterHub
|
2
2
|
class ApiResource
|
3
3
|
include Operations::Get
|
4
|
-
attr_accessor :id, :opts
|
4
|
+
attr_accessor :id, :opts, :attributes
|
5
5
|
|
6
6
|
def initialize(id=nil, opts={})
|
7
7
|
@id = id
|
8
8
|
@opts = opts
|
9
9
|
@values = {}
|
10
|
+
@attributes = {}
|
10
11
|
end
|
11
12
|
|
12
13
|
def self.class_name
|
@@ -17,12 +18,17 @@ module GifterHub
|
|
17
18
|
if self == ApiResource
|
18
19
|
raise NotImplementedError
|
19
20
|
end
|
20
|
-
"/api
|
21
|
+
"/api/#{CGI.escape(class_name.tableize)}"
|
21
22
|
end
|
22
23
|
|
23
24
|
def self.get(id, opts={})
|
24
25
|
instance = self.new(id, opts)
|
25
26
|
instance.refresh
|
27
|
+
instance
|
28
|
+
end
|
29
|
+
|
30
|
+
def inspect
|
31
|
+
JSON.pretty_generate(attributes)
|
26
32
|
end
|
27
33
|
|
28
34
|
def resource_url
|
@@ -36,30 +42,18 @@ module GifterHub
|
|
36
42
|
|
37
43
|
private
|
38
44
|
|
39
|
-
def self.check_id!(id)
|
40
|
-
raise TypeError.new('id should be a string') unless id.is_a? String
|
41
|
-
id
|
42
|
-
end
|
43
|
-
|
44
|
-
def protected_fields
|
45
|
-
[]
|
46
|
-
end
|
47
|
-
|
48
45
|
# Convert hash key value pair to method
|
49
46
|
def initialize_from(values, opts={})
|
50
47
|
@opts = opts
|
51
48
|
added = Set.new(values.keys - @values.keys)
|
52
|
-
|
53
|
-
|
54
|
-
end
|
49
|
+
@attributes = values
|
50
|
+
add_accessors(added, values)
|
55
51
|
self
|
56
52
|
end
|
57
53
|
|
58
54
|
def add_accessors(keys, values)
|
59
|
-
f = protected_fields
|
60
55
|
metaclass.instance_eval do
|
61
56
|
keys.each do |k|
|
62
|
-
next if f.include?(k)
|
63
57
|
define_method(k) { values[k] }
|
64
58
|
|
65
59
|
if [FalseClass, TrueClass].include?(values[k].class)
|
data/lib/gifter_hub/gift_card.rb
CHANGED
data/lib/gifter_hub/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gifter_hub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Devhub
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,7 +94,7 @@ files:
|
|
94
94
|
- lib/gifter_hub/api_resource.rb
|
95
95
|
- lib/gifter_hub/errors/api_connection_error.rb
|
96
96
|
- lib/gifter_hub/errors/api_error.rb
|
97
|
-
- lib/gifter_hub/errors/
|
97
|
+
- lib/gifter_hub/errors/gifter_hub_error.rb
|
98
98
|
- lib/gifter_hub/gift_card.rb
|
99
99
|
- lib/gifter_hub/operations/create.rb
|
100
100
|
- lib/gifter_hub/operations/get.rb
|