wherever-positions 0.4.4 → 0.4.5

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.4
1
+ 0.4.5
data/lib/string_helper.rb CHANGED
@@ -1,14 +1,15 @@
1
1
  module StringHelper
2
2
  class << self
3
- def add_method_to_id(strings)
3
+ def add_method_to_id(strings, as_array=true)
4
4
  return nil unless strings
5
- strings.each do |string|
5
+ strings.map do |string|
6
6
  if string.is_a?(Array)
7
- add_method_to_id(string)
7
+ add_method_to_id(string, false)
8
8
  else
9
9
  def string.to_id
10
10
  "#{self}_id"
11
11
  end
12
+ as_array ? [string] : string
12
13
  end
13
14
  end
14
15
  end
@@ -13,8 +13,7 @@ class Configure
13
13
  config.master = mongo_connection
14
14
  end
15
15
 
16
- @keys = StringHelper.add_method_to_id(options["keys"])
17
- groups = StringHelper.add_method_to_id(options["key_groups"]) || @keys
18
- @key_groups = groups.map{|g| Array(g)}
16
+ @keys = StringHelper.add_method_to_id(options["keys"], false)
17
+ @key_groups = StringHelper.add_method_to_id(options["key_groups"] || options["keys"])
19
18
  end
20
19
  end
@@ -7,7 +7,7 @@ module DbStore
7
7
  field :current, :type => String
8
8
 
9
9
  def keys
10
- StringHelper.add_method_to_id(self['keys'])
10
+ @keys ||= StringHelper.add_method_to_id(read_attribute('keys'), false)
11
11
  end
12
12
  end
13
13
 
data/spec/spec_helper.rb CHANGED
@@ -5,7 +5,7 @@ require 'wherever'
5
5
  require 'ruby-debug'
6
6
  require 'database_cleaner'
7
7
 
8
- Wherever.new("keys" => ["fund_id"], "database" => 'wherever_test')
8
+ Wherever.new("keys" => ["fund"], "database" => 'wherever_test')
9
9
 
10
10
  # Requires supporting files with custom matchers and macros, etc,
11
11
  # in ./support/ and its subdirectories.
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wherever-positions}
8
- s.version = "0.4.4"
8
+ s.version = "0.4.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David Henry"]
12
- s.date = %q{2011-11-04}
12
+ s.date = %q{2011-11-05}
13
13
  s.description = %q{Allow Store of positions by multiple keys with teh option to mark specific points in time for use later}
14
14
  s.email = %q{dw_henry@yahoo.com.au}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wherever-positions
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 4
10
- version: 0.4.4
9
+ - 5
10
+ version: 0.4.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Henry
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-04 00:00:00 +00:00
18
+ date: 2011-11-05 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency