hashifiable 0.0.1
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 +7 -0
- data/lib/hashifiable.rb +20 -0
- data/lib/hashifiable/version.rb +13 -0
- metadata +63 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4593d7b77aa53d337d252b6b18cab6c1b721c3b1
|
4
|
+
data.tar.gz: 5df540d21a9b2a2285f8152e540320d04a4416e3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 43e7566f9693b90c9b7c82c7596dabd3ac555af73a2d46e47df3a77107acfefdc49d5264b8d27f4d061dbcf916c14e52e1bd97940f6a05c9013f231412420878
|
7
|
+
data.tar.gz: a34751881d0b560ad86dc4bfabb70951bbf3e948d1e9386078e98bf9adbe92b7f4a898daaf204c3e82da49a48b284c03a2f7339cee06aaedb06667c2bc72acfb
|
data/lib/hashifiable.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Hashifiable
|
4
|
+
def hashify(*args)
|
5
|
+
## Defines to_hash with specified arguments.
|
6
|
+
define_method :to_hash do
|
7
|
+
hash_representation = {}
|
8
|
+
args.each do |attribute|
|
9
|
+
hash_representation[attribute] = self.send(attribute)
|
10
|
+
end
|
11
|
+
|
12
|
+
hash_representation
|
13
|
+
end
|
14
|
+
|
15
|
+
## Defines to_json based on the to_hash method.
|
16
|
+
define_method :to_json do
|
17
|
+
self.to_hash.to_json
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hashifiable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pablo Astigrraga
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: "\n With hashify you can specify a line with the methods that will
|
28
|
+
be called to\n create a hash representation of your object. Simple and straightforward.\n
|
29
|
+
\ "
|
30
|
+
email:
|
31
|
+
- poteland@gmail.com
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- lib/hashifiable/version.rb
|
37
|
+
- lib/hashifiable.rb
|
38
|
+
homepage: http://github.com/pote/hashify
|
39
|
+
licenses:
|
40
|
+
- MIT
|
41
|
+
metadata: {}
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 2.0.0.rc.2
|
60
|
+
signing_key:
|
61
|
+
specification_version: 4
|
62
|
+
summary: A simple way to specify the hash/json representation of your object
|
63
|
+
test_files: []
|