scopie 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a712c48ae4d6541f9de46f7161944622035f5dca
4
- data.tar.gz: a3ab1963d878729f75219ee9f8a48891c208abba
3
+ metadata.gz: 4e34647423993b787e22d9ac7e981916eb0762fd
4
+ data.tar.gz: 202a069ca12680313e90eb6d09da4e631a1f73a4
5
5
  SHA512:
6
- metadata.gz: 13f994ef566f8d582a1e28f1213a25463b0aed03ec3c0131fc97760bed5897768835e7eb1fa5e12f4feb4966f0e799ddbb655f74658e205914f2466191cfc296
7
- data.tar.gz: 0e37d4f423664bceb1d44c9f3e2db4906fd4f591040ae8814662289364a08787f369eca26e4d4572e236725fc3c6d9bcb5552cb08ad8f28f76403db442138375
6
+ metadata.gz: 25ab1c44e41e21bf8e33d4377aae792ec22825bddb8aa23d794a7502894f416999cd5bcae6e6f29e3c1046d82f8acfc3c1a22005ac21773a1482d698d4accb86
7
+ data.tar.gz: 7f4198b1614e31350b6f2a0615de4b24420f0d8367868c7937378c625a4005bffa5a23483d28bf26a70445397b66f1e14a020e25e14cff888a1915b90143ebb7
data/README.md CHANGED
@@ -26,6 +26,7 @@ class Graduation < ActiveRecord::Base
26
26
 
27
27
  scope :created_at_greater_than, ->(date) { where('entities.created_at >= ?', date.beginning_of_day) }
28
28
  scope :created_at_less_than, ->(date) { where('entities.created_at <= ?', date.end_of_day) }
29
+
29
30
  scope :updated_at_greater_than, ->(date) { where('entities.updated_at >= ?', date.beginning_of_day) }
30
31
  scope :updated_at_less_than, ->(date) { where('entities.updated_at <= ?', date.end_of_day) }
31
32
 
@@ -43,6 +44,9 @@ class GraduationsScopie < Scopie::Base
43
44
  has_scope :created_at_greater_than, in: :created_at, as: :start_at
44
45
  has_scope :created_at_less_than, in: :created_at, as: :end_at
45
46
 
47
+ has_scope :updated_at_greater_than, in: :updated_at, as: :start_at, type: :date
48
+ has_scope :updated_at_less_than, in: :updated_at, as: :end_at, type: :date
49
+
46
50
  has_scope :page, default: 1
47
51
  has_scope :per, default: 30
48
52
 
@@ -61,6 +65,14 @@ class GraduationsScopie < Scopie::Base
61
65
  scope.created_at_less_than(parse_date(value))
62
66
  end
63
67
 
68
+ def updated_at_greater_than(scope, value, _hash)
69
+ scope.updated_at_greater_than(value)
70
+ end
71
+
72
+ def updated_at_less_than(scope, value, _hash)
73
+ scope.updated_at_less_than(value)
74
+ end
75
+
64
76
  private
65
77
 
66
78
  def parse_date(value)
@@ -113,7 +125,7 @@ gem 'scopie'
113
125
 
114
126
  Scopie supports several options:
115
127
 
116
- * `:type` - Coerces the type of the parameter sent. Available options: boolean, integer, date.
128
+ * `:type` - Coerces the type of the parameter sent. Available options: boolean, integer, float, date.
117
129
 
118
130
  * `:only` - In which actions the scope is applied.
119
131
 
data/lib/scopie/base.rb CHANGED
@@ -83,6 +83,10 @@ class Scopie::Base
83
83
  Date.parse(value)
84
84
  end
85
85
 
86
+ def coerce_to_float(value)
87
+ Float(value)
88
+ end
89
+
86
90
  def scope_applicable?(value, options, method)
87
91
  return false unless method_applicable?(method, options)
88
92
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Scopie
3
- VERSION = '0.7.0'
3
+ VERSION = '0.8.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scopie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Kotov