time_for_a_boolean 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +4 -4
- data/Rakefile +0 -5
- data/lib/time_for_a_boolean.rb +5 -4
- data/lib/time_for_a_boolean/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5acc839630f48b9206cd7dd07d15f4563e3d43eefc039a4fd069df0e2cc0aa21
|
4
|
+
data.tar.gz: 0aaf6fa56776b9b934c7a317f9eea6eada121dd24da494b3a1a0294b97d30771
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bd9a2ed4952d33d5a85f47b146f90d1d646078f36cc94052e8fbd76fa20ebcb6ea182351ca9f11436146996fd292d8f9feeeb3b3ce7a9418948e614dfe442be
|
7
|
+
data.tar.gz: 48d4a07e21aa180fe8117115bb23f1a6bb21e1e94376926f36872ac4d3e52ea0df53c16e427ea49e69bfb2c52be2fc0cc0d2d9bc9a9ae7b5261fb1477c5e5aa9
|
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Time for A Boolean
|
2
2
|
==================
|
3
3
|
|
4
|
-
[![Build Status](https://api.travis-ci.org/calebthompson/time_for_a_boolean.
|
5
|
-
[![Code Climate](https://codeclimate.com/github/calebthompson/time_for_a_boolean.
|
6
|
-
[![Coverage Status](https://coveralls.io/repos/calebthompson/time_for_a_boolean/badge.
|
4
|
+
[![Build Status](https://api.travis-ci.org/calebthompson/time_for_a_boolean.svg?branch=master)](https://travis-ci.org/calebthompson/time_for_a_boolean)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/calebthompson/time_for_a_boolean.svg)](https://codeclimate.com/github/calebthompson/time_for_a_boolean)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/calebthompson/time_for_a_boolean/badge.svg)](https://coveralls.io/r/calebthompson/time_for_a_boolean)
|
7
7
|
|
8
8
|
|
9
9
|
> Sally: Hey, we need to add a flag to Post
|
@@ -63,7 +63,7 @@ methods are defined:
|
|
63
63
|
|
64
64
|
| Method | Description
|
65
65
|
| --------------- | -----------
|
66
|
-
| `Post#deleted` | `true` if `Post#deleted_at` is set to a
|
66
|
+
| `Post#deleted` | `true` if `Post#deleted_at` is set to a time before `Time.current`, `false` otherwise
|
67
67
|
| `Post#deleted?` | Alias for `Post#deleted`
|
68
68
|
| `Post#deleted=` | Sets the timestamp to `Time.current` if the new value is true, and `nil` otherwise
|
69
69
|
|
data/Rakefile
CHANGED
data/lib/time_for_a_boolean.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "active_support/core_ext/module/delegation"
|
2
|
-
require "
|
2
|
+
require "active_support/core_ext/time/calculations"
|
3
|
+
require "active_model/type"
|
3
4
|
require "time_for_a_boolean/version"
|
4
5
|
require "time_for_a_boolean/railtie"
|
5
6
|
|
@@ -13,10 +14,10 @@ module TimeForABoolean
|
|
13
14
|
|
14
15
|
setter_attribute = "#{field}="
|
15
16
|
define_method("#{attribute}=") do |value|
|
16
|
-
if
|
17
|
-
send(setter_attribute, -> { Time.current }.())
|
18
|
-
else
|
17
|
+
if ActiveModel::Type::Boolean::FALSE_VALUES.include?(value)
|
19
18
|
send(setter_attribute, nil)
|
19
|
+
else
|
20
|
+
send(setter_attribute, -> { Time.current }.())
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_for_a_boolean
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caleb Thompson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.6.14
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Back boolean values with timestamps
|