sequel-attribute_callbacks 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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c86323078c1bbdd9eb54064ad9eeb75b9941c35d
|
4
|
+
data.tar.gz: d219e62c1052581cca87af63234a0bc8106f2447
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdc18ac6de5dbe5f270a32111930f8fb09ede2496210a97b8b0d17f99116b47e2885fe1d758a4995d39787bb2475a87a62863c4c045cc5a6f1544d3dd94c904b
|
7
|
+
data.tar.gz: 991f382b752d07d1b595419dd0861645a0eb0875527ca2379c359cfb68695108e1283bebf65500d233b74c7179f9d528c5f55a0d980415cf7a36a6c56ccf6232
|
data/LICENSE.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2013
|
1
|
+
Copyright (c) 2013 Conjur, Inc.
|
2
2
|
|
3
3
|
MIT License
|
4
4
|
|
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -10,8 +10,12 @@ module Sequel::Plugins::AttributeCallbacks
|
|
10
10
|
end
|
11
11
|
|
12
12
|
module RichDataCloner
|
13
|
+
def self.apply model
|
14
|
+
model.plugin :after_initialize
|
15
|
+
end
|
16
|
+
|
13
17
|
module InstanceMethods
|
14
|
-
def
|
18
|
+
def after_initialize
|
15
19
|
super
|
16
20
|
clone_rich_attributes
|
17
21
|
end
|
data/spec/callbacks_spec.rb
CHANGED
@@ -88,7 +88,30 @@ describe 'attribute_callbacks plugin' do
|
|
88
88
|
i.save.should be
|
89
89
|
model.first.colors.should == ['red', 'blue']
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
|
+
describe "and an initializer" do
|
93
|
+
let(:model) do
|
94
|
+
class Widget < Sequel::Model
|
95
|
+
plugin :attribute_callbacks
|
96
|
+
def initialize _ = {}
|
97
|
+
super _
|
98
|
+
|
99
|
+
self.colors ||= [].pg_array
|
100
|
+
end
|
101
|
+
end
|
102
|
+
Widget
|
103
|
+
end
|
104
|
+
|
105
|
+
it "works too" do
|
106
|
+
i = model.create colors: ['red']
|
107
|
+
i = model.first
|
108
|
+
i.should_receive(:before_colors_add).with('blue').and_return true
|
109
|
+
i.colors << 'blue'
|
110
|
+
i.save.should be
|
111
|
+
model.first.colors.should == ['red', 'blue']
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
92
115
|
it "work with in place modification" do
|
93
116
|
i = model.create colors: ['red']
|
94
117
|
i.should_receive(:before_colors_add).with('blue').and_return true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel-attribute_callbacks
|
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
|
- Rafał Rzepecki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|