scopie 1.0.2 → 1.0.3

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: 879319e399691c122f8202cc78ecf59acf738d60
4
- data.tar.gz: f2c747c9a891dca955f175e7b351900af5cce454
3
+ metadata.gz: 5437b5335d372d559a4d07e873999cad8e65cde2
4
+ data.tar.gz: f82f54898eab51611111625c633c176fb26187a0
5
5
  SHA512:
6
- metadata.gz: e50053ba1c7a8817dc0960cbe47640c9a588f2944539bdd608cf42b03b9022ac110c970c6ae60f82c7b0fad5db6f902321d57925645fcb2bd7fd494b28c7a457
7
- data.tar.gz: 2361436b73bf383a370817d48b305d6a0b05d322f22841ea1109ce76eb9ba888d412abfbe46172e28f0503aabfd97cc81ef236b4746cde434b253d02c68834a5
6
+ metadata.gz: b7cf7460e1fb19a77a4bd15b68a1609d25ef7b1216428e149a425ddd0428ad3698b40724706631319403408dfb1def209d848bd6edbb4f8df720a901d9e5d770
7
+ data.tar.gz: 07fe08d3b2d86ddb3921d65a44d40c4148c71b4b06e6887978e0d53e9bee04435c963df0a2a9327d9eafb1f7297229b4f8b6f1375cadb1f46de0b8cee7b46ce7
data/lib/scopie/value.rb CHANGED
@@ -1,11 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Scopie::Value < Struct.new(:hash, :key_name, :options)
3
+ class Scopie::Value
4
4
 
5
5
  TRUE_VALUES = ['true', true, '1', 1].freeze
6
6
 
7
+ def initialize(hash, key_name, options)
8
+ @hash = hash
9
+ @key_name = key_name
10
+ @options = options
11
+ end
12
+
7
13
  def raw
8
- return hash[key_name] if hash.key?(key_name)
14
+ return @hash[@key_name] if @hash.key?(@key_name)
9
15
  fetch_default
10
16
  end
11
17
 
@@ -14,15 +20,15 @@ class Scopie::Value < Struct.new(:hash, :key_name, :options)
14
20
  end
15
21
 
16
22
  def fetch_type
17
- options[:type]
23
+ @options[:type]
18
24
  end
19
25
 
20
26
  def fetch_default
21
- options[:default]
27
+ @options[:default]
22
28
  end
23
29
 
24
30
  def has_default?
25
- options.key?(:default)
31
+ @options.key?(:default)
26
32
  end
27
33
 
28
34
  def given?
@@ -30,7 +36,7 @@ class Scopie::Value < Struct.new(:hash, :key_name, :options)
30
36
  end
31
37
 
32
38
  def key_passed?
33
- hash.key?(key_name)
39
+ @hash.key?(@key_name)
34
40
  end
35
41
 
36
42
  def present?
@@ -45,7 +51,7 @@ class Scopie::Value < Struct.new(:hash, :key_name, :options)
45
51
 
46
52
  coercion_method_name = "coerce_to_#{type}"
47
53
 
48
- respond_to?(coercion_method_name, true) || fail(Scopie::InvalidOptionError.new("Unknown value for option 'type' provided: :#{type}"))
54
+ respond_to?(coercion_method_name, true) || raise(Scopie::InvalidOptionError.new, "Unknown value for option 'type' provided: :#{type}")
49
55
 
50
56
  send(coercion_method_name, value)
51
57
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Scopie
4
- VERSION = '1.0.2'
4
+ VERSION = '1.0.3'
5
5
  end
data/lib/scopie.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Scopie
4
-
5
4
  class InvalidOptionError < StandardError; end
6
5
 
7
6
  RESULTS_TO_IGNORE = [true, false].freeze
@@ -16,5 +15,4 @@ module Scopie
16
15
  def self.current_scopes(hash, method: nil, scopie: Scopie::Base.new)
17
16
  scopie.current_scopes(hash, method)
18
17
  end
19
-
20
18
  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: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Kotov