embedson 1.0.3 → 1.0.4
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 +8 -8
- data/README.md +3 -0
- data/lib/embedson/model/embeds_builder.rb +1 -1
- data/lib/embedson/model/method_builder.rb +4 -0
- data/lib/embedson/version.rb +1 -1
- data/spec/embedson/model/method_builder_spec.rb +22 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NThiNzZmNzBkMTA2Mzg0OGVmZWJhMGI0Yzc3MmVjYWFjN2JjYTA2ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDg1Njk0ODlmNGI3OTY0OTZjMmFiMDY0YzM3NjIxYTkyYTIxOGNlMA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjBkMmQxN2JhMzBiOWZiOTQ3ZjI1OGJiZDFkMDBjN2Y2NzUwZDFmNjNkMWE4
|
10
|
+
NWUwZDExOTc1YzZhMWY0ODgzOTlmMDYwYTQyNGQ3Yjk5ODk3Yzg1OGVhMDIx
|
11
|
+
ZDdlMjkzYTRhZDcxNDEyNzJiZmQ2MzBlNGRmNDZkN2QzNWM1YzE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Y2JmODUxMDljZTc4MDhkNWJiNDI2MmU1NTUyNjkyNzU3Nzc4NTE4Yzc2ODFm
|
14
|
+
MTU2NjBkZmExOGI4MmI1YjU5MjBhZDVlZWNmOTI3YmVlMTlkNzdiYzEwMzk0
|
15
|
+
Yzg4ODUxYzY0MWM4YzA4M2ZmZTkwYWZiNmZiMmY3NzM3MmY2ODE=
|
data/README.md
CHANGED
@@ -32,6 +32,9 @@ Or install it yourself as:
|
|
32
32
|
|
33
33
|
## Usage
|
34
34
|
|
35
|
+
Example with [Searchlight](https://github.com/nathanl/searchlight) is described
|
36
|
+
in blogpost ["Persistent queries in Ruby on Rails with PostgreSQL"](https://netguru.co/blog/persistent-queries-in-ruby-on-rails).
|
37
|
+
|
35
38
|
Example with [Virtus](https://github.com/solnic/virtus):
|
36
39
|
|
37
40
|
```RUBY
|
@@ -26,7 +26,7 @@ module Embedson
|
|
26
26
|
send("#{builder.field_name}_send_to_related", arg)
|
27
27
|
|
28
28
|
instance_variable_set(builder.instance_var_name, arg)
|
29
|
-
val = arg.nil? ? arg : arg.
|
29
|
+
val = arg.nil? ? arg : arg.send(builder.hash_method).stringify_keys
|
30
30
|
unless val == read_attribute(builder.column_name)
|
31
31
|
write_attribute(builder.column_name, val)
|
32
32
|
end
|
data/lib/embedson/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Embedson::Model::MethodBuilder do
|
4
|
+
|
5
|
+
describe '#hash_method' do
|
6
|
+
context 'when option :hash_method is defined' do
|
7
|
+
let(:builder) { described_class.new(nil, :name, { hash_method: 'method' }) }
|
8
|
+
|
9
|
+
it 'returns its value' do
|
10
|
+
expect(builder.hash_method).to eq 'method'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when options :hash_method is not defined' do
|
15
|
+
let(:builder) { described_class.new(nil, :name, {}) }
|
16
|
+
|
17
|
+
it 'returns :to_h' do
|
18
|
+
expect(builder.hash_method).to eq :to_h
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: embedson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sufleR
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/embedson/version.rb
|
147
147
|
- spec/embedson/exceptions_spec.rb
|
148
148
|
- spec/embedson/model/embedded_builder_spec.rb
|
149
|
+
- spec/embedson/model/method_builder_spec.rb
|
149
150
|
- spec/embedson/model_spec.rb
|
150
151
|
- spec/spec_helper.rb
|
151
152
|
homepage: https://github.com/sufleR/embedson
|
@@ -175,5 +176,6 @@ summary: Embedded model for AR with postgresql
|
|
175
176
|
test_files:
|
176
177
|
- spec/embedson/exceptions_spec.rb
|
177
178
|
- spec/embedson/model/embedded_builder_spec.rb
|
179
|
+
- spec/embedson/model/method_builder_spec.rb
|
178
180
|
- spec/embedson/model_spec.rb
|
179
181
|
- spec/spec_helper.rb
|