hash_store 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d20653833590acd7440f21df77f05a4534c37989
4
- data.tar.gz: bb346d67ded438d67c61977136aa8f2ab85dbcf4
3
+ metadata.gz: 3e2a6831f333bc961fabbd75c1a76befa3f558e1
4
+ data.tar.gz: cc50c20c53d662875ab9f68ec67b2937b997f1ef
5
5
  SHA512:
6
- metadata.gz: 396256c0ff8ffb3aae139e0087a251abfea1bb796667894ccc2c056e1ea170de4d02e8551f0358912d328200be4bad3f5ed22b1e2c6284b46f34879a3023b5a0
7
- data.tar.gz: a83cec0b8eb9fb016e76b251747a13b72717d0c4f13856366900f9d37fd26b46bb1d5ce75d0b3f8eb62079feb71b41e494ebd357b81501693be3ed552dfaaba6
6
+ metadata.gz: f7466ed78d318e5fc89178189eaf960e8f3327d5d127c7de9f3f54f30ceaa4dc712c0177ff0e178aa48e2f3010a5401fcc78f40196e2a1e66680f5541470fa98
7
+ data.tar.gz: a8cd54dd56d9c61843e84b3d5a0990bc7ebaa3c1aa5b88426590db82bf7ce91a886d8944870b59b3586fb750f9034091420494b27a1ff78e8ed600c91b22e3e2
@@ -3,10 +3,10 @@
3
3
  module HashStore::Base
4
4
  module ClassMethods
5
5
  def hash_store(name=nil, options={})
6
- unless self.ancestors.include?(ActiveRecord::Base)
6
+ if !defined?(ActiveRecord::Base) || !self.ancestors.include?(ActiveRecord::Base)
7
7
  begin
8
- raise unless options[:hash].present?
9
- raise unless options[:key].present?
8
+ raise if options[:hash].nil?
9
+ raise if options[:key].nil?
10
10
  rescue => e
11
11
  print <<-EOS
12
12
  When using hash_store on Non-ActiveRecord class, you MUST pass name and options(:key and :hash) arguments.
@@ -18,15 +18,15 @@ EOS
18
18
 
19
19
  method_suffix = (name.nil? || name == '') ? '' : "_#{name}"
20
20
 
21
- if options[:hash].present?
21
+ if !options[:hash].nil?
22
22
  hs_hash_proc = options[:hash]
23
23
  else
24
24
  hs_hash_proc = ->(model){ model.as_json(root: false, except: [:created_at, :updated_at]) }
25
25
  end
26
26
 
27
- if options[:key].present?
27
+ if !options[:key].nil?
28
28
  hs_key_proc = options[:key]
29
- elsif name.present? && options[:key].nil?
29
+ elsif method_suffix != '' && options[:key].nil?
30
30
  hs_key_proc = ->(model){ "#{model.class.table_name}:#{name}:#{model.id}" }
31
31
  else
32
32
  hs_key_proc = ->(model){ "#{model.class.table_name}:#{model.id}" }
@@ -62,7 +62,7 @@ EOS
62
62
  define_singleton_method "get_hash#{method_suffix}" do |key, options=nil|
63
63
  json = HashStore::Config.redis.get(key)
64
64
  return nil if json.nil?
65
- return json if options.present? && options[:json]
65
+ return json if !options.nil? && options[:json]
66
66
  MultiJson.decode(json)
67
67
  end
68
68
 
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module HashStore
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - M.Iwasaki(Curi)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-25 00:00:00.000000000 Z
11
+ date: 2013-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis