sneaky-save 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 +5 -13
- data/VERSION +1 -1
- data/lib/sneaky-save.rb +11 -1
- data/sneaky-save.gemspec +3 -1
- data/spec/lib/sneaky_save_spec.rb +9 -1
- data/spec/spec_helper.rb +3 -0
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
OWZkMzVhZjE2NjdjY2Q5ZGJiMWZiMDFhYjhmOTI0NmRjNTMwNzBkNA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c3b6ca175d2aea91a1b934f2fee91f215f7680e7
|
4
|
+
data.tar.gz: ea88947b9b5aff370ebeab4d10e0a10806245f40
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZWQ3MzcyMmI1ZDI4ZWNiZDk4ZWViYTM3MjFhZjA2NmQ2MzQ0OTViZjFlNDlk
|
11
|
-
NTU3MDUxMTAwOWEwZTAxYTEzNTgwNTQ1NzZlZjRkOTc2NjFkODg=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
Mzg5ZTFjZGNkMTVmM2E4OWYzNTNmMzkyZjMyZjliZWVlMGI0MGY3YzBmN2E1
|
14
|
-
ZGI3ZWJiMmE0MzJkZDUwNTkwYmIyZjU5MzFhMjk1YTJjNDg5M2I3YzFmZjlh
|
15
|
-
YjNlYmViMDRlZTQxZTc4NmM1MGQwNWVmNzIzMTMwZTViNDY5MzM=
|
6
|
+
metadata.gz: d076eb382b8cac2832f63ee962ec1148d3ef5dd8bab7897320d49122ca152ac4083c8ee2b7540dae0fba5f47fba5061e610d2b105898c04fe61ea5ac7c353abc
|
7
|
+
data.tar.gz: '09602f2f9dfe467846b84674e52480d90978cb8b4ce8b4a172f504604c360d5afeb09a5bdb7450a97217e20e909fedf2a5d72573e06680439cce593e07adc237'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/sneaky-save.rb
CHANGED
@@ -68,8 +68,18 @@ module SneakySave
|
|
68
68
|
pk = self.class.primary_key
|
69
69
|
original_id = changed_attributes.key?(pk) ? changes[pk].first : send(pk)
|
70
70
|
|
71
|
+
changed_attributes = sneaky_update_fields
|
72
|
+
|
73
|
+
# Serialize values for rails3 before updating
|
74
|
+
unless sneaky_new_rails?
|
75
|
+
serialized_fields = self.class.serialized_attributes.keys & changed_attributes.keys
|
76
|
+
serialized_fields.each do |field|
|
77
|
+
changed_attributes[field] = @attributes[field].serialized_value
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
71
81
|
!self.class.where(pk => original_id).
|
72
|
-
update_all(
|
82
|
+
update_all(changed_attributes).zero?
|
73
83
|
end
|
74
84
|
|
75
85
|
def sneaky_attributes_values
|
data/sneaky-save.gemspec
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
+
version = File.read(File.expand_path("VERSION", __dir__)).strip
|
4
|
+
|
3
5
|
Gem::Specification.new do |s|
|
4
6
|
s.name = %q{sneaky-save}
|
5
|
-
s.version =
|
7
|
+
s.version = version
|
6
8
|
|
7
9
|
s.date = %q{2016-08-06}
|
8
10
|
s.authors = ["Sergei Zinin (einzige)"]
|
@@ -30,6 +30,13 @@ describe SneakySave, use_connection: true do
|
|
30
30
|
expect_any_instance_of(Fake).to_not receive(:valid?)
|
31
31
|
subject.sneaky_save
|
32
32
|
end
|
33
|
+
|
34
|
+
it "updates serialized column" do
|
35
|
+
subject.config = { test: "test" }
|
36
|
+
expect(subject.sneaky_save).to eq(true)
|
37
|
+
subject.reload
|
38
|
+
expect(subject.config).to eq(test: "test")
|
39
|
+
end
|
33
40
|
end
|
34
41
|
|
35
42
|
describe "#sneaky_save!" do
|
@@ -71,10 +78,11 @@ describe SneakySave, use_connection: true do
|
|
71
78
|
|
72
79
|
it "stores attributes in database" do
|
73
80
|
subject.name = "new name"
|
81
|
+
subject.config = {test: "test"}
|
74
82
|
expect(subject.sneaky_save).to eq(true)
|
75
83
|
subject.reload
|
76
84
|
expect(subject.name).to eq("new name")
|
77
|
-
expect(subject.
|
85
|
+
expect(subject.config).to eq(test: "test")
|
78
86
|
end
|
79
87
|
|
80
88
|
it "does not call any callback" do
|
data/spec/spec_helper.rb
CHANGED
@@ -9,6 +9,7 @@ shared_context "use connection", use_connection: true do
|
|
9
9
|
create_table "fakes" do |table|
|
10
10
|
table.column :name, :string, null: false
|
11
11
|
table.column :belonger_id, :integer
|
12
|
+
table.column :config, :text
|
12
13
|
end
|
13
14
|
|
14
15
|
create_table "belongers" do |table|
|
@@ -26,6 +27,8 @@ shared_context "use connection", use_connection: true do
|
|
26
27
|
|
27
28
|
belongs_to :belonger
|
28
29
|
|
30
|
+
serialize :config, Hash
|
31
|
+
|
29
32
|
def before_save_callback
|
30
33
|
"BEFORE SAVE CALLED"
|
31
34
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sneaky-save
|
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
|
- Sergei Zinin (einzige)
|
@@ -14,28 +14,28 @@ dependencies:
|
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: ActiveRecord extension. Allows to save record without calling callbacks
|
@@ -46,8 +46,8 @@ extensions: []
|
|
46
46
|
extra_rdoc_files:
|
47
47
|
- README.md
|
48
48
|
files:
|
49
|
-
- .gitignore
|
50
|
-
- .travis.yml
|
49
|
+
- ".gitignore"
|
50
|
+
- ".travis.yml"
|
51
51
|
- Gemfile
|
52
52
|
- README.md
|
53
53
|
- Rakefile
|
@@ -69,17 +69,17 @@ require_paths:
|
|
69
69
|
- lib
|
70
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- -
|
72
|
+
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
|
-
- -
|
77
|
+
- - ">="
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.5.2
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: Allows to save record without calling callbacks and validations.
|