hashifiable 0.1.0 → 0.1.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.
data/lib/hashifiable.rb CHANGED
@@ -1,14 +1,16 @@
1
- require 'json'
2
-
3
1
  module Hashifiable
2
+
4
3
  def hashify(*args)
5
4
 
6
- ## Defines to_hash method dinamically with the key/values specified in *args.
7
- define_method :to_hash do
5
+ ## Defines to_hash method dinamically with the key/values specified
6
+ ## in *args.
7
+ define_method :to_h do
8
8
  hash_representation = {}
9
9
 
10
10
  methods = args.select { |a| a.is_a?(Symbol) }
11
- procs = args.select { |a| a.is_a?(Hash) }.inject { |all, hash| all.merge(hash) }
11
+ procs = args.select { |a| a.is_a?(Hash) }.inject do |all, hash|
12
+ all.merge(hash)
13
+ end
12
14
 
13
15
  ## Create keys for all lambdas sent.
14
16
  procs.each do |name, function|
@@ -23,9 +25,6 @@ module Hashifiable
23
25
  hash_representation
24
26
  end
25
27
 
26
- ## Defines to_json based on the to_hash method.
27
- define_method :to_json do
28
- self.to_hash.to_json
29
- end
28
+ alias_method :to_hash, :to_h
30
29
  end
31
30
  end
@@ -2,7 +2,7 @@ module Hashifiable
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- PATCH = 0
5
+ PATCH = 1
6
6
 
7
7
  def self.to_s
8
8
  [MAJOR, MINOR, PATCH].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashifiable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: