has_defaults 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.3.2.mysql2.lock +1 -1
- data/Gemfile.4.2.mysql2.lock +1 -1
- data/Gemfile.4.2.pg.lock +1 -1
- data/Gemfile.5.2.mysql2.lock +1 -1
- data/Gemfile.5.2.pg.lock +1 -1
- data/Gemfile.6.1.pg.lock +1 -1
- data/Gemfile.7.0.pg.lock +1 -1
- data/README.md +6 -6
- data/lib/has_defaults/active_record_ext.rb +3 -3
- data/lib/has_defaults/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 699a82dd69eb3ae0e29640deef82f676973939af56412ac5ca976de1d6d73518
|
4
|
+
data.tar.gz: 48c12946f600f3becd44af5e2c8067e08fc802576d68fa2e9ca8b1e19385af1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9aa21669bba0d8ab54f752702e5da7f3438f3dd1feb9a233d8ed095940a9575f11e2ae906bdcd5484897d0ebe41abfc60cdd0ab83806dcb97dcc4da76017bcce
|
7
|
+
data.tar.gz: cf3e65d6cd134ff80cd06af116f6200e360fef62ce5e40a6d87b96b7b0890a972fe0693513f1f6bf5006b9e65991a84c2735d684ce19f0552c1d5d9e17f4c1c5
|
data/CHANGELOG.md
CHANGED
@@ -11,6 +11,13 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
|
|
11
11
|
### Compatible changes
|
12
12
|
|
13
13
|
|
14
|
+
## 1.2.1 - 2024-10-25
|
15
|
+
|
16
|
+
### Compatible changes
|
17
|
+
|
18
|
+
* Follow recommended way to extend Railties
|
19
|
+
|
20
|
+
|
14
21
|
## 1.2.0 - 2023-03-15
|
15
22
|
|
16
23
|
### Breaking changes
|
data/Gemfile.3.2.mysql2.lock
CHANGED
data/Gemfile.4.2.mysql2.lock
CHANGED
data/Gemfile.4.2.pg.lock
CHANGED
data/Gemfile.5.2.mysql2.lock
CHANGED
data/Gemfile.5.2.pg.lock
CHANGED
data/Gemfile.6.1.pg.lock
CHANGED
data/Gemfile.7.0.pg.lock
CHANGED
data/README.md
CHANGED
@@ -6,13 +6,13 @@ Default values for ActiveRecord models.
|
|
6
6
|
|
7
7
|
In your `Gemfile`
|
8
8
|
|
9
|
-
```
|
9
|
+
```rb
|
10
10
|
gem 'has_defaults'
|
11
11
|
```
|
12
12
|
|
13
13
|
Now run
|
14
14
|
|
15
|
-
```
|
15
|
+
```sh
|
16
16
|
bundle install
|
17
17
|
```
|
18
18
|
|
@@ -20,7 +20,7 @@ bundle install
|
|
20
20
|
|
21
21
|
Add the method call `has_defaults` to your model.
|
22
22
|
|
23
|
-
```
|
23
|
+
```rb
|
24
24
|
class Page < ActiveRecord::Base
|
25
25
|
has_defaults :title => "New page", :body => "Put your text here"
|
26
26
|
end
|
@@ -30,19 +30,19 @@ Attributes will be set only if it's a new record and the attribute is blank.
|
|
30
30
|
|
31
31
|
Retrieve the default attribute with the `default_for` instance method:
|
32
32
|
|
33
|
-
```
|
33
|
+
```rb
|
34
34
|
@page.default_for(:title)
|
35
35
|
```
|
36
36
|
|
37
37
|
You can pass Proc as attribute:
|
38
38
|
|
39
|
-
```
|
39
|
+
```rb
|
40
40
|
has_defaults :expires_at => proc { Time.now }
|
41
41
|
```
|
42
42
|
|
43
43
|
You can override the default attributes as follow:
|
44
44
|
|
45
|
-
```
|
45
|
+
```rb
|
46
46
|
Page.has_defaults_options = {:title => "Here's your new page", :body => "Write your page text"}
|
47
47
|
```
|
48
48
|
|
data/lib/has_defaults/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_defaults
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henning Koch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|