scopie 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e34647423993b787e22d9ac7e981916eb0762fd
4
- data.tar.gz: 202a069ca12680313e90eb6d09da4e631a1f73a4
3
+ metadata.gz: 837a34b1643dff78c53060a3f2e3dec10c7551a5
4
+ data.tar.gz: 136edd4dc6a54d32ea9877eb0f8d45dcd6bc75be
5
5
  SHA512:
6
- metadata.gz: 25ab1c44e41e21bf8e33d4377aae792ec22825bddb8aa23d794a7502894f416999cd5bcae6e6f29e3c1046d82f8acfc3c1a22005ac21773a1482d698d4accb86
7
- data.tar.gz: 7f4198b1614e31350b6f2a0615de4b24420f0d8367868c7937378c625a4005bffa5a23483d28bf26a70445397b66f1e14a020e25e14cff888a1915b90143ebb7
6
+ metadata.gz: 3bd549c2f9b837aa053d48cb7a19ac31bf55b2c4d858c86d77215b3ed4baa53d49b466e3fcbb4ba82a4f19fa1147c76ecd3e6779e4b50bd416cd27ebe8963a7d
7
+ data.tar.gz: 805125337eb5574256967213d91ea037ff23bb87a186e9db40ae893450b904a5bd6d1ca155bab136eb7f8cbcbdfa3c1059eec4873896882215b7e49fd8e7795d
data/README.md CHANGED
@@ -24,11 +24,11 @@ class Graduation < ActiveRecord::Base
24
24
  scope :by_degree, -> (degree) { where(degree: degree) }
25
25
  scope :by_period, -> (started_at, ended_at) { where('started_at = ? AND ended_at = ?', started_at, ended_at) }
26
26
 
27
- scope :created_at_greater_than, ->(date) { where('entities.created_at >= ?', date.beginning_of_day) }
28
- scope :created_at_less_than, ->(date) { where('entities.created_at <= ?', date.end_of_day) }
27
+ scope :created_at_greater_than, ->(date) { where('created_at >= ?', date.beginning_of_day) }
28
+ scope :created_at_less_than, ->(date) { where('created_at <= ?', date.end_of_day) }
29
29
 
30
- scope :updated_at_greater_than, ->(date) { where('entities.updated_at >= ?', date.beginning_of_day) }
31
- scope :updated_at_less_than, ->(date) { where('entities.updated_at <= ?', date.end_of_day) }
30
+ scope :updated_at_greater_than, ->(date) { where('updated_at >= ?', date.beginning_of_day) }
31
+ scope :updated_at_less_than, ->(date) { where('updated_at <= ?', date.end_of_day) }
32
32
 
33
33
  end
34
34
  ```
data/lib/scopie.rb CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Scopie
4
4
 
5
+ class InvalidOptionError < StandardError; end
6
+
5
7
  require 'scopie/base'
6
8
 
7
9
  def self.apply_scopes(target, hash, method: nil, scopie: Scopie::Base.new)
data/lib/scopie/base.rb CHANGED
@@ -68,7 +68,12 @@ class Scopie::Base
68
68
 
69
69
  def coerce_value_type(value, type)
70
70
  return value unless type
71
- send("coerce_to_#{type}", value)
71
+
72
+ coercion_method_name = "coerce_to_#{type}"
73
+
74
+ respond_to?(coercion_method_name, true) || fail(Scopie::InvalidOptionError.new("Unknown value for option 'type' provided: :#{type}"))
75
+
76
+ send(coercion_method_name, value)
72
77
  end
73
78
 
74
79
  def coerce_to_boolean(value)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Scopie
3
- VERSION = '0.8.0'
4
+ VERSION = '0.8.1'
4
5
  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.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Kotov