usable 3.0.0 → 3.1.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: 18d15fe43c88882ead95863b946d7ee496b37bff
4
- data.tar.gz: 06d47996bebf7e130062441d55e5104f39635dbc
3
+ metadata.gz: 33cffc63217bfad4d6b90e50f2e1d3651e93a64f
4
+ data.tar.gz: 313140dd2d024f0d2f7d3cd52c2cb3449d13d979
5
5
  SHA512:
6
- metadata.gz: 8ffbe8e76c89a3f04eaf70dc4edc61aaa9e03f80cc06c567ec99146108515e1c2a594c7def908ac622d0483b6e90bb0f2380a309066e4c31a5cc2e836c341a2e
7
- data.tar.gz: 35c77816de2bbf4a99bbd33fdc9c2754cafcc2ea3f39f0719b8b34315a3fb62cc66f885d8074df396a2b472b1cc902d76516eaca1e179ef7adc20fbd897e6c25
6
+ metadata.gz: 61d7f8a61d3bbfe2caa0e7577e411596e293333cc2a2419c989c57845c53cf22973cd6476ef28aa58826586df814ce0107150d333c3b5ce59908bfd8e6ac3e92
7
+ data.tar.gz: 61143864455490a58c8526e0b5f2216cdfb3dc7c829b8e1b108832c5f5b4fd714868799353f9e339d2ad76fbd9219955d4c996077557e1c1bdddd0cadc043e63
data/lib/usable/config.rb CHANGED
@@ -10,6 +10,7 @@ module Usable
10
10
 
11
11
  def initialize
12
12
  @spec = OpenStruct.new
13
+ @lazy_loads = Set.new
13
14
  end
14
15
 
15
16
  def each(&block)
@@ -37,13 +38,22 @@ module Usable
37
38
  spec key, val
38
39
  end
39
40
 
41
+ def to_h
42
+ @lazy_loads.each { |key| spec(key) }
43
+ _spec.to_h
44
+ end
45
+
46
+ alias to_hash to_h
47
+
40
48
  def call_lazy_method(key)
41
- @spec.public_send(key.to_s.tr('=', ''))
49
+ @lazy_loads.delete key
50
+ @spec.public_send key.to_s.tr('=', '')
42
51
  end
43
52
 
44
53
  def method_missing(method_name, *args, &block)
45
54
  if block
46
55
  _spec.define_singleton_method(method_name) { yield }
56
+ @lazy_loads << method_name
47
57
  else
48
58
  spec method_name, *args
49
59
  end
@@ -1,3 +1,3 @@
1
1
  module Usable
2
- VERSION = "3.0.0".freeze
2
+ VERSION = "3.1.0".freeze
3
3
  end
data/lib/usable.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'set'
1
2
  require 'ostruct'
2
3
  require 'delegate'
3
4
  require 'usable/version'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usable
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Buckley
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-05 00:00:00.000000000 Z
11
+ date: 2016-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler