hashifiable 0.0.1 → 0.1.0
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.
- data/lib/hashifiable.rb +13 -2
- data/lib/hashifiable/version.rb +2 -2
- metadata +32 -12
- checksums.yaml +0 -7
data/lib/hashifiable.rb
CHANGED
@@ -2,10 +2,21 @@ require 'json'
|
|
2
2
|
|
3
3
|
module Hashifiable
|
4
4
|
def hashify(*args)
|
5
|
-
|
5
|
+
|
6
|
+
## Defines to_hash method dinamically with the key/values specified in *args.
|
6
7
|
define_method :to_hash do
|
7
8
|
hash_representation = {}
|
8
|
-
|
9
|
+
|
10
|
+
methods = args.select { |a| a.is_a?(Symbol) }
|
11
|
+
procs = args.select { |a| a.is_a?(Hash) }.inject { |all, hash| all.merge(hash) }
|
12
|
+
|
13
|
+
## Create keys for all lambdas sent.
|
14
|
+
procs.each do |name, function|
|
15
|
+
hash_representation[name] = instance_exec(&function)
|
16
|
+
end
|
17
|
+
|
18
|
+
## Create keys for all methods specified.
|
19
|
+
methods.each do |attribute|
|
9
20
|
hash_representation[attribute] = self.send(attribute)
|
10
21
|
end
|
11
22
|
|
data/lib/hashifiable/version.rb
CHANGED
metadata
CHANGED
@@ -1,32 +1,51 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashifiable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Pablo Astigrraga
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-20 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
13
30
|
- !ruby/object:Gem::Dependency
|
14
31
|
name: rspec
|
15
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
16
34
|
requirements:
|
17
|
-
- - '>='
|
35
|
+
- - ! '>='
|
18
36
|
- !ruby/object:Gem::Version
|
19
37
|
version: '0'
|
20
38
|
type: :development
|
21
39
|
prerelease: false
|
22
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
23
42
|
requirements:
|
24
|
-
- - '>='
|
43
|
+
- - ! '>='
|
25
44
|
- !ruby/object:Gem::Version
|
26
45
|
version: '0'
|
27
|
-
description: "\n With hashify you can specify a line with the methods that
|
28
|
-
be called to\n create a hash representation of your object. Simple and
|
29
|
-
|
46
|
+
description: ! "\n With hashify you can specify a line with the methods that
|
47
|
+
will be called to\n create a hash representation of your object. Simple and
|
48
|
+
straightforward.\n "
|
30
49
|
email:
|
31
50
|
- poteland@gmail.com
|
32
51
|
executables: []
|
@@ -38,26 +57,27 @@ files:
|
|
38
57
|
homepage: http://github.com/pote/hashify
|
39
58
|
licenses:
|
40
59
|
- MIT
|
41
|
-
metadata: {}
|
42
60
|
post_install_message:
|
43
61
|
rdoc_options: []
|
44
62
|
require_paths:
|
45
63
|
- lib
|
46
64
|
- lib
|
47
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
48
67
|
requirements:
|
49
|
-
- - '>='
|
68
|
+
- - ! '>='
|
50
69
|
- !ruby/object:Gem::Version
|
51
70
|
version: '0'
|
52
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
53
73
|
requirements:
|
54
|
-
- - '>='
|
74
|
+
- - ! '>='
|
55
75
|
- !ruby/object:Gem::Version
|
56
76
|
version: '0'
|
57
77
|
requirements: []
|
58
78
|
rubyforge_project:
|
59
|
-
rubygems_version:
|
79
|
+
rubygems_version: 1.8.23
|
60
80
|
signing_key:
|
61
|
-
specification_version:
|
81
|
+
specification_version: 3
|
62
82
|
summary: A simple way to specify the hash/json representation of your object
|
63
83
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 4593d7b77aa53d337d252b6b18cab6c1b721c3b1
|
4
|
-
data.tar.gz: 5df540d21a9b2a2285f8152e540320d04a4416e3
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 43e7566f9693b90c9b7c82c7596dabd3ac555af73a2d46e47df3a77107acfefdc49d5264b8d27f4d061dbcf916c14e52e1bd97940f6a05c9013f231412420878
|
7
|
-
data.tar.gz: a34751881d0b560ad86dc4bfabb70951bbf3e948d1e9386078e98bf9adbe92b7f4a898daaf204c3e82da49a48b284c03a2f7339cee06aaedb06667c2bc72acfb
|