attribute-defaults 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/attribute_defaults.rb +4 -7
- metadata +36 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ca26a4bb71d7a6dad922776645c493a4f2d58cc03bb291feea88fcb0261a4733
|
4
|
+
data.tar.gz: 3b8d8b4f8d65d70b6af9d57a25c789c56161c7bb218814ee418d97076a803f49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5f998d1fc6475947b94ccd778afe5e643686e2c0ee1a3dfb051add7975b0d0c34b2d35c60be8c1ac57a5b595ccd8c35765566857daf3fe6dbd1ef71caf0cb54
|
7
|
+
data.tar.gz: 767367fc27c227f774b61272081f96eb39ae62cbaa630bb6636f1eeef8849f1c652558b6df68e8c1c7343fedb62b3c8f3198257413203086096c7282b5511294
|
data/lib/attribute_defaults.rb
CHANGED
@@ -6,7 +6,6 @@ module ActiveRecord
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
module ClassMethods
|
9
|
-
|
10
9
|
# Set defaults. Examples:
|
11
10
|
# attr_default :age, 12
|
12
11
|
# attr_default :description, '(none)'
|
@@ -41,20 +40,18 @@ module ActiveRecord
|
|
41
40
|
end
|
42
41
|
|
43
42
|
# Default mass-assignment. Examples:
|
44
|
-
# attr_defaults
|
45
|
-
# attr_defaults
|
46
|
-
# attr_defaults
|
43
|
+
# attr_defaults description: '(none)', age: 12
|
44
|
+
# attr_defaults description: '(none)', age: ->r { Time.zone.year - r.dob.year }
|
45
|
+
# attr_defaults description: '(none)', age: { default: 12, persisted: false }
|
47
46
|
def attr_defaults(pairs)
|
48
47
|
pairs.each do |pair|
|
49
|
-
attr_default
|
48
|
+
attr_default(*pair)
|
50
49
|
end
|
51
50
|
end
|
52
|
-
|
53
51
|
end
|
54
52
|
end
|
55
53
|
|
56
54
|
class Base
|
57
55
|
include AttributesWithDefaults
|
58
56
|
end
|
59
|
-
|
60
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attribute-defaults
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitrij Denissenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 5.0.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 7.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 5.0.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 7.0.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rake
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: rspec
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
@@ -59,7 +59,35 @@ dependencies:
|
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
62
|
+
name: rubocop
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rubocop-performance
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: sqlite3
|
63
91
|
requirement: !ruby/object:Gem::Requirement
|
64
92
|
requirements:
|
65
93
|
- - ">="
|
@@ -93,15 +121,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
121
|
requirements:
|
94
122
|
- - ">="
|
95
123
|
- !ruby/object:Gem::Version
|
96
|
-
version: 2.
|
124
|
+
version: 2.5.0
|
97
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
126
|
requirements:
|
99
127
|
- - ">="
|
100
128
|
- !ruby/object:Gem::Version
|
101
129
|
version: '0'
|
102
130
|
requirements: []
|
103
|
-
|
104
|
-
rubygems_version: 2.6.8
|
131
|
+
rubygems_version: 3.1.2
|
105
132
|
signing_key:
|
106
133
|
specification_version: 4
|
107
134
|
summary: Specify default values for ActiveRecord attributes
|