attribute-defaults 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/attribute_defaults.rb +7 -7
- metadata +5 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38c546a1c23c35b30ed286726bbf47f7202708cbf1fcce9614766e98bee3af60
|
4
|
+
data.tar.gz: 8ec2f406c28b50e74ddcc1650ed9e7aded34b47f1787b9eb313e7a000caf59fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5aee2bd1dad485a2aa2333a2a47654ae56c8e25880a242420abe3d06792120c02e8f8e07f115cc2ba0b071ea1744f496e1731bb62db05cd65c1f8cbdf2620bfe
|
7
|
+
data.tar.gz: a2d5ea51c06d1b56c4281d512531ab2bf2d5cdd08c267b765be2ea37019eb338f881a183c14a8151fb9ca179cb9bef32b65fb30bb3b99ef1b0c43521f6ab9fd9
|
data/lib/attribute_defaults.rb
CHANGED
@@ -28,13 +28,13 @@ module ActiveRecord
|
|
28
28
|
define_method(evaluator, &block)
|
29
29
|
|
30
30
|
module_eval(<<-EVAL, __FILE__, __LINE__ + 1)
|
31
|
-
def #{setter}
|
32
|
-
#{'return if persisted?' if options[:persisted] == false}
|
33
|
-
return unless
|
34
|
-
value = #{evaluator}#{'(self)' unless block.arity.zero?}
|
35
|
-
self.#{sym} = value.duplicable? ? value.dup : value
|
36
|
-
rescue ActiveModel::MissingAttributeError
|
37
|
-
end
|
31
|
+
def #{setter} # def __set_attr_default_for_age
|
32
|
+
#{'return if persisted?' if options[:persisted] == false} # return if persisted?
|
33
|
+
return unless #{sym}.send(:#{options[:if] || 'nil?'}) # return unless age.nil?
|
34
|
+
value = #{evaluator}#{'(self)' unless block.arity.zero?} # value = __eval_attr_default_for_age(self)
|
35
|
+
self.#{sym} = value.duplicable? ? value.dup : value # self.age = value.duplicable? ? value.dup : value
|
36
|
+
rescue ActiveModel::MissingAttributeError # rescue ActiveModel::MissingAttributeError
|
37
|
+
end # end
|
38
38
|
EVAL
|
39
39
|
private evaluator, setter
|
40
40
|
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.9.
|
4
|
+
version: 0.9.1
|
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: 2021-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -59,21 +59,7 @@ dependencies:
|
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
- !ruby/object:Gem::Dependency
|
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
|
62
|
+
name: rubocop-bsm
|
77
63
|
requirement: !ruby/object:Gem::Requirement
|
78
64
|
requirements:
|
79
65
|
- - ">="
|
@@ -121,14 +107,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
107
|
requirements:
|
122
108
|
- - ">="
|
123
109
|
- !ruby/object:Gem::Version
|
124
|
-
version: 2.
|
110
|
+
version: '2.6'
|
125
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
112
|
requirements:
|
127
113
|
- - ">="
|
128
114
|
- !ruby/object:Gem::Version
|
129
115
|
version: '0'
|
130
116
|
requirements: []
|
131
|
-
rubygems_version: 3.1.
|
117
|
+
rubygems_version: 3.1.4
|
132
118
|
signing_key:
|
133
119
|
specification_version: 4
|
134
120
|
summary: Specify default values for ActiveRecord attributes
|