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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0a3f13b858e4857c633577f31c6b20f539f585d
4
- data.tar.gz: 6b9dcfcc01106db15a135723b10167a760010422
3
+ metadata.gz: bdebc65cab9ef1e17b1dff6bea474ca0c2942596
4
+ data.tar.gz: fb2de38d09eda799925fff20ca7b99f188891b20
5
5
  SHA512:
6
- metadata.gz: 42fb53956ab84dcb4ba25b615c99ce842c75e1aad9fb111f2d9a45c751e2496f9fc458a677e85643f5a07c15c01ca901b86359cdd41c63ab700db90ec1ec0282
7
- data.tar.gz: 4fcd1a3fcaedb3a0701ee00594902b329412c3dbd2008544d3a0d8fe6652dd78dfefcd4b9d85a4c2befbc54a210360acb9185bdb8e5c5dc3535a2c297ec01c69
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
- name = @name || klass.name.split('::').last.downcase
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('name') { name }
82
+ define_singleton_method('key') { key }
68
83
  end
69
84
  end
70
85
 
71
- [:filters, :endpoint, :name].each do |att|
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
@@ -52,7 +52,7 @@ module WCC
52
52
  def find(id)
53
53
  resp = client.get("#{model.endpoint}/#{id}")
54
54
  resp.assert_ok!
55
- model.new(resp.body[model.name], resp.headers.freeze)
55
+ model.new(resp.body[model.key], resp.headers.freeze)
56
56
  end
57
57
 
58
58
  def list(**filters)
@@ -3,7 +3,7 @@ require_relative '../../../rest_client'
3
3
  module WCC
4
4
  module Media
5
5
  class Client < RestClient
6
- VERSION = '0.2.1'.freeze
6
+ VERSION = '0.2.2'.freeze
7
7
  end
8
8
  end
9
9
  end
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.1
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-20 00:00:00.000000000 Z
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.6.11
179
+ rubygems_version: 2.5.2
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: ''