hash_map 0.5.0 → 0.5.1

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: 6bae76ad044288eb46403cd3ea870146d210bc91
4
- data.tar.gz: 268a72ffcdc09a0e79a1c7bce05adbeb7f3b3ee2
3
+ metadata.gz: c57bc95e7052c0c47f51335a0ba7b4d155234666
4
+ data.tar.gz: 6bfb54eb1d57266248d651a42bb55a495195c287
5
5
  SHA512:
6
- metadata.gz: 6b938e9d58a66274c45b34769ed5de353189b62c0d4b59ade8a6307057c7accadc4b2b64cd0429186c36e133c322c852ab401fc31d58dc5bfc6797c1989ccfe6
7
- data.tar.gz: 4dc6a6f3ab70adbb9e31592614f5dee586d9911f7e99a9df8e8311c2aeaf2041ffb99a48f2f8219fb07d473beaac4701c5e9eee1ced7de66b23860b584a6a544
6
+ metadata.gz: 3bb511c4e06c8ce12fc1420238006d0e36a16971bab43cf249b887252a8963e6a300f3b93bfd85e34dc83528c8064ec4ddd95a318ee045efd9b442e250d68640
7
+ data.tar.gz: 84296666688feac7b1227b8aa9e9ba0ea97d11f53f4caedc4ce1d5fbf18d4b3d09fe09a435ca0dff0a36a407e05a5cb67917ef0aa3a9d6b274276e4adce5ae0c
data/README.md CHANGED
@@ -144,6 +144,22 @@ Collections.map({ numbers: '1'})
144
144
  numbers: [1]
145
145
  }
146
146
  ```
147
+ **Options**
148
+ Adding a second argument will make it available with the name `options`
149
+
150
+ ```ruby
151
+ class UserMapper < HashMap::Base
152
+ properties :name, :lastname
153
+ property :company_name do
154
+ options[:company_name]
155
+ end
156
+ end
157
+
158
+ user = {name: :name, lastname: :lastname}
159
+
160
+ UserMapper.map(user, company_name: :foo)
161
+ #=> {"name"=>:name, "lastname"=>:lastname, "company_name"=>:foo}
162
+ ```
147
163
 
148
164
  **Inheritance**
149
165
  When inheriting from a Mapper child will inherit the properties
data/lib/hash_map/base.rb CHANGED
@@ -2,8 +2,8 @@ module HashMap
2
2
  class Base
3
3
  delegate :[], to: :output
4
4
 
5
- def self.map(input)
6
- new(input).output
5
+ def self.map(*args)
6
+ new(*args).output
7
7
  end
8
8
  singleton_class.send(:alias_method, :call, :map)
9
9
 
@@ -15,9 +15,10 @@ module HashMap
15
15
  end
16
16
  end
17
17
 
18
- attr_reader :original
19
- def initialize(original)
18
+ attr_reader :original, :options
19
+ def initialize(original, options = {})
20
20
  @original = _transforms_input(prepare_input(original))
21
+ @options = options
21
22
  end
22
23
 
23
24
  def mapper
@@ -1,3 +1,3 @@
1
1
  module HashMap
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_map
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artur Pañach
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-12 00:00:00.000000000 Z
11
+ date: 2017-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  requirements: []
119
119
  rubyforge_project:
120
- rubygems_version: 2.2.3
120
+ rubygems_version: 2.4.5
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: Library to map easily hashes.