tablesalt 0.9.2 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 124513ebba0f74fd84bca0383de07005d4e52d7b72f947a6fbdeec57559b5013
4
- data.tar.gz: 4fee0882a20b9c074ed1d25c6139e3d20638adb68e46d5046831b51f23c4295e
3
+ metadata.gz: 4dad7e20ae350e0e54f884e2fca05f59004d428968fe8c657d59000058f6e9cc
4
+ data.tar.gz: d7fa448bdcf15b765b931665ba80eaf0cc58d31efba04caf4ccff89cde17c872
5
5
  SHA512:
6
- metadata.gz: e15058e2d8357cdfdc3c6173b6fe6f2956f3060b3a3ad5a7fb0db778d720a93bfb744f63cc85e5a3b41c2301b35014fc9f4016edb845d8826c3e6f2723f7d02d
7
- data.tar.gz: 3614f29903caee7ca7b30ef8215ac7fa5acd0604baff9f338e4de6484fa47a234af439599545c3905a918e0840d2a3c2cc424d524ef5f701db83d091e084d15b
6
+ metadata.gz: e8d1b8afa60670037d4c7f3b37de22cf750ee90e49284abea6b3758f20d21a1ebe249729538d4dd6951026250b9af625d689900928f66c5b9885214e525bb689
7
+ data.tar.gz: f5db473feff15d8f9bd0c1008edf0041b0f0d459d2ad0c8ddbb5b3ebd6e44386f8e5dab5204033a3cc4c3a9698a152e8fd2b122c6ff657159b045ca5ffa81ab7
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tablesalt
4
+ class ArrayIndex
5
+ class << self
6
+ alias_method :[], :new
7
+ end
8
+
9
+ attr_reader :array
10
+
11
+ delegate :[], to: :index
12
+
13
+ def initialize(array)
14
+ @array = array.deep_dup
15
+ end
16
+
17
+ def index
18
+ @index ||= array.each_with_index.each_with_object({}) do |(element, index), hash|
19
+ hash[element] = index unless hash.key?(element)
20
+ end
21
+ end
22
+
23
+ def freeze
24
+ index.freeze
25
+ array.freeze
26
+ super
27
+ end
28
+ end
29
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Tablesalt
4
4
  # This constant is managed by spicerack
5
- VERSION = "0.9.2"
5
+ VERSION = "0.9.5"
6
6
  end
data/lib/tablesalt.rb CHANGED
@@ -4,6 +4,7 @@ require "active_support"
4
4
 
5
5
  require "tablesalt/version"
6
6
 
7
+ require "tablesalt/array_index"
7
8
  require "tablesalt/hash_model"
8
9
 
9
10
  module Tablesalt; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tablesalt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Minneti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-17 00:00:00.000000000 Z
11
+ date: 2019-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -49,6 +49,7 @@ files:
49
49
  - LICENSE.txt
50
50
  - README.md
51
51
  - lib/tablesalt.rb
52
+ - lib/tablesalt/array_index.rb
52
53
  - lib/tablesalt/hash_model.rb
53
54
  - lib/tablesalt/version.rb
54
55
  homepage: https://github.com/Freshly/spicerack/tree/master/tablesalt