tarvit-helpers 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/VERSION +1 -1
- data/lib/tarvit-helpers/modules/hash_presenter.rb +7 -7
- data/spec/modules/hash_presenter_spec.rb +1 -0
- data/tarvit-helpers.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a13746e7d24e16878b2c73fdf642d0fce34ae3e
|
4
|
+
data.tar.gz: ddd2d104db9c6b76848d756b63a9b741a4b12196
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 934ddc0317b7d562c4b9d4f839c0cf16865229de27608aa4a1e36c3a999293c3ac9c3bbd04a644bcb6878201dd6fa048a75007ca2e4fb8e2191b4c0f8c9b2d0e
|
7
|
+
data.tar.gz: 708e3d499006efdff36776ae8063e0781e345e641745aadd0e32c63bf98c7bea06c7860301bb736c157a25e912fb8957f06357b41d329920b798b7e0fd15060f
|
data/README.md
CHANGED
@@ -56,6 +56,23 @@ B.value
|
|
56
56
|
=> 3
|
57
57
|
```
|
58
58
|
|
59
|
+
HashPresenter module allows to present hashes as pure ojects.
|
60
|
+
```ruby
|
61
|
+
hp = HashPresenter.present({ a: 1, b: 2 })
|
62
|
+
hp.a
|
63
|
+
=> 1
|
64
|
+
hp.b
|
65
|
+
=> 2
|
66
|
+
|
67
|
+
original = { a: 1, b: 2 }
|
68
|
+
observer = HashPresenter.present(original, :observable)
|
69
|
+
observer.a
|
70
|
+
=> 1
|
71
|
+
original[:a] = 3
|
72
|
+
observer.a
|
73
|
+
=> 3
|
74
|
+
```
|
75
|
+
|
59
76
|
|
60
77
|
**Contributing to tarvit-helpers**
|
61
78
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.12
|
@@ -13,10 +13,10 @@ module TarvitHelpers
|
|
13
13
|
class SimpleHashPresenter
|
14
14
|
require 'active_support/core_ext/string'
|
15
15
|
|
16
|
-
attr_reader :
|
16
|
+
attr_reader :_hash
|
17
17
|
|
18
18
|
def initialize(hash)
|
19
|
-
@
|
19
|
+
@_hash = prepare_keys(hash)
|
20
20
|
end
|
21
21
|
|
22
22
|
def method_missing(m, *args)
|
@@ -27,7 +27,7 @@ module TarvitHelpers
|
|
27
27
|
protected
|
28
28
|
|
29
29
|
def value(method_name)
|
30
|
-
res = self.
|
30
|
+
res = self._hash[method_name]
|
31
31
|
transform_value(res)
|
32
32
|
end
|
33
33
|
|
@@ -37,7 +37,7 @@ module TarvitHelpers
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def accessor_method?(method_name)
|
40
|
-
self.
|
40
|
+
self._hash.keys.include?(method_name)
|
41
41
|
end
|
42
42
|
|
43
43
|
def key_to_method(key)
|
@@ -68,11 +68,11 @@ module TarvitHelpers
|
|
68
68
|
|
69
69
|
class ObservableHashPresenter < SimpleHashPresenter
|
70
70
|
def initialize(hash)
|
71
|
-
@
|
71
|
+
@_hash = hash
|
72
72
|
end
|
73
73
|
|
74
|
-
def
|
75
|
-
prepare_keys(@
|
74
|
+
def _hash
|
75
|
+
prepare_keys(@_hash)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
data/tarvit-helpers.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: tarvit-helpers 0.0.
|
5
|
+
# stub: tarvit-helpers 0.0.12 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "tarvit-helpers"
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.12"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Vitaly Tarasenko"]
|
14
|
-
s.date = "2015-10-
|
14
|
+
s.date = "2015-10-23"
|
15
15
|
s.description = " Simple extensions to standard Ruby classes and useful helpers. "
|
16
16
|
s.email = "vetal.tarasenko@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tarvit-helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitaly Tarasenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|