wcc-media-client 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wcc/media/active_record_shim.rb +19 -4
- data/lib/wcc/media/client.rb +1 -1
- data/lib/wcc/media/client/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: bdebc65cab9ef1e17b1dff6bea474ca0c2942596
|
4
|
+
data.tar.gz: fb2de38d09eda799925fff20ca7b99f188891b20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fdc78d6d575372c7baf3af8b3c24b2f02e6552fd1bbe52a00a460c9fa77f17125347cf9a05e9418a91cf46c8304582f80ceaa5570f31fcabda6adbae896d859
|
7
|
+
data.tar.gz: dbcaacd089831a1cd9d05badaeadc2e77e499c2fcea72c7961fa9f190cf32172cd4d2c70b6bd751a5b700a3e13b9edf1a9f0224d4382d262a95df8f0d52db61f
|
@@ -6,7 +6,16 @@ module WCC::Media::ActiveRecordShim
|
|
6
6
|
|
7
7
|
module InstanceMethods
|
8
8
|
def attributes
|
9
|
-
raw
|
9
|
+
raw.keys.each_with_object({}) do |key, h|
|
10
|
+
next unless respond_to?(key)
|
11
|
+
val = public_send(key)
|
12
|
+
h[key] =
|
13
|
+
if val.is_a? Array
|
14
|
+
val.map { |v| v.respond_to?(:to_h) ? v.to_h : v }
|
15
|
+
else
|
16
|
+
val.respond_to?(:to_h) ? val.to_h : val
|
17
|
+
end
|
18
|
+
end
|
10
19
|
end
|
11
20
|
end
|
12
21
|
|
@@ -54,21 +63,27 @@ module WCC::Media::ActiveRecordShim
|
|
54
63
|
|
55
64
|
find_all(filter).each_slice(batch_size, &block)
|
56
65
|
end
|
66
|
+
|
67
|
+
def where(**conditions)
|
68
|
+
# TODO: return a Query object that implements more of the ActiveRecord query interface
|
69
|
+
# https://guides.rubyonrails.org/active_record_querying.html#conditions
|
70
|
+
find_all(conditions)
|
71
|
+
end
|
57
72
|
end
|
58
73
|
|
59
74
|
class ShimBuilder
|
60
75
|
def apply(klass)
|
61
76
|
filters = (@filters || []).freeze
|
62
77
|
endpoint = @endpoint || klass.name.split('::').last.downcase
|
63
|
-
|
78
|
+
key = @key || klass.name.split('::').last.downcase
|
64
79
|
klass.instance_eval do
|
65
80
|
define_singleton_method('filters') { filters }
|
66
81
|
define_singleton_method('endpoint') { endpoint }
|
67
|
-
define_singleton_method('
|
82
|
+
define_singleton_method('key') { key }
|
68
83
|
end
|
69
84
|
end
|
70
85
|
|
71
|
-
[:filters, :endpoint, :
|
86
|
+
[:filters, :endpoint, :key].each do |att|
|
72
87
|
class_eval("def #{att}(value); @#{att} = value; end", __FILE__, __LINE__)
|
73
88
|
end
|
74
89
|
end
|
data/lib/wcc/media/client.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wcc-media-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Watermark Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
176
|
version: '0'
|
177
177
|
requirements: []
|
178
178
|
rubyforge_project:
|
179
|
-
rubygems_version: 2.
|
179
|
+
rubygems_version: 2.5.2
|
180
180
|
signing_key:
|
181
181
|
specification_version: 4
|
182
182
|
summary: ''
|