dcidev_active_record 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -1
- data/lib/dcidev_active_record.rb +3 -3
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2f414077e25a60a2125212a12f9ae9139f4fce7ee01215616eee2da5570de7d
|
4
|
+
data.tar.gz: a8245cd2d0e6ea3b3bc94bee724070dcf614a21796b1dbc617213c419bdedc6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '07590e79636f220a44f31d777d9a9fa43782b704960db95bd7da430d41f28ce924181a93529165d3dcd7cd808a4c896a4cb828af72aa23ce15a95f883552d98e'
|
7
|
+
data.tar.gz: 280180a70a2453932642e80503d5619c01035f2ac5102bca34886483dadef94f79c95ebcee62e8474a2650d726b3db63e2bef595495a57c66ecc506bc97b7355
|
data/README.md
CHANGED
@@ -1 +1,41 @@
|
|
1
|
-
|
1
|
+
# How to Use
|
2
|
+
add `DB= mysql / postgresql` to your `.env` file
|
3
|
+
|
4
|
+
# Features
|
5
|
+
|
6
|
+
### Query Scope Filtering
|
7
|
+
```ruby
|
8
|
+
model.between_date(column, start_date, end_date)
|
9
|
+
model.before_or_equal_to_date(date, date)
|
10
|
+
model.after_or_equal_to_date(column, date)
|
11
|
+
model.at_time(column, time)
|
12
|
+
model.mysql_json_contains(column, key, value)
|
13
|
+
```
|
14
|
+
|
15
|
+
### Class Method
|
16
|
+
```ruby
|
17
|
+
# initialize using hash, the model is not saved yet
|
18
|
+
Model.new_from_params(params)
|
19
|
+
|
20
|
+
# convert from UTC to server date
|
21
|
+
Model.mysql_date_builder(column)
|
22
|
+
|
23
|
+
# convert from UTC to server time
|
24
|
+
Model.mysql_time_builder(column)
|
25
|
+
|
26
|
+
# same as above but for postgresql
|
27
|
+
Model.postgresql_date_builder(column)
|
28
|
+
Model.postgresql_time_builder(column)
|
29
|
+
```
|
30
|
+
|
31
|
+
### Instance Method
|
32
|
+
```ruby
|
33
|
+
# update a record using hash parameter
|
34
|
+
# if set_nil = true, the unspesified column will be automatically be set to nil
|
35
|
+
model.update_by_params(params, set_nil = true)
|
36
|
+
|
37
|
+
# available for one-many relationship
|
38
|
+
# replace all child of this model with specified value from array
|
39
|
+
# set model accepts_nested_attributes_for :child,allow_destroy: true
|
40
|
+
model.replace_child_from_array(new_child = [], column_name: "", child_name: "")
|
41
|
+
```
|
data/lib/dcidev_active_record.rb
CHANGED
@@ -105,16 +105,16 @@ module DcidevActiveRecord
|
|
105
105
|
"TIME(CONVERT_TZ(#{field}, '+00:00', '#{Time.now.in_time_zone(Time.zone.name.to_s).formatted_offset}'))"
|
106
106
|
end
|
107
107
|
|
108
|
-
def
|
108
|
+
def pgsql_date_builder(field)
|
109
109
|
"DATE(#{field}::TIMESTAMPTZ AT TIME ZONE '#{Time.zone.now.formatted_offset}'::INTERVAL)"
|
110
110
|
end
|
111
111
|
|
112
|
-
def
|
112
|
+
def pgsql_time_builder(field)
|
113
113
|
"#{field}::TIMESTAMPTZ AT TIME ZONE '#{Time.zone.now.formatted_offset}'"
|
114
114
|
end
|
115
115
|
|
116
116
|
def db_like_string(db)
|
117
|
-
return 'ILIKE' if db == '
|
117
|
+
return 'ILIKE' if db == 'pgsql'
|
118
118
|
return 'LIKE' if db == 'mysql'
|
119
119
|
end
|
120
120
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dcidev_active_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Punto Damar P
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Testing phase
|
14
14
|
email:
|
@@ -19,10 +19,10 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- README.md
|
21
21
|
- lib/dcidev_active_record.rb
|
22
|
-
homepage:
|
22
|
+
homepage:
|
23
23
|
licenses: []
|
24
24
|
metadata: {}
|
25
|
-
post_install_message:
|
25
|
+
post_install_message:
|
26
26
|
rdoc_options: []
|
27
27
|
require_paths:
|
28
28
|
- lib
|
@@ -37,8 +37,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '0'
|
39
39
|
requirements: []
|
40
|
-
rubygems_version: 3.
|
41
|
-
signing_key:
|
40
|
+
rubygems_version: 3.0.3.1
|
41
|
+
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: This gem extends ActiveRecord features
|
44
44
|
test_files: []
|