looksist 0.1.4 → 0.1.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
  SHA1:
3
- metadata.gz: 46c6ea1a931ae0e7367b6448d23c37cb12d73cf2
4
- data.tar.gz: 0d6ff0d198ece2ec4a3b8f4cdf1e60e7748e3ff5
3
+ metadata.gz: 52851b1abadfa5c5e0e753e84291b22643b25d21
4
+ data.tar.gz: d6cde88e787c76b7a18048ceb7c968f0f9094f10
5
5
  SHA512:
6
- metadata.gz: 11993fd0f01590a1ad5cc85f64d1cda21608cc8a74f380501dd1b935aa43ce810cee112167dc36b9c3f7e176de65263ceb487386c7a1e654963af2fd01c5cdde
7
- data.tar.gz: 4fd89a0710c78b8626886d67fc15f6455a9f1e7b8b5545e8252075c789d7958820298273820614bdc804c093edcbb34ca97d0bf3dc63ee02e6c5ef14eb578409
6
+ metadata.gz: 7e693cb1c71e42a59e51be1ae75e7c2d9830ca5289cef58cc5dc5f0123a743e558b0bd648600c2a6966a415354ccd065face0051f4b0e8747a791aad1827b286
7
+ data.tar.gz: 563492167cc926ab5c282bb16c2e4473eee199c2a6152543ba8e725d15fe5a530db3ead9c8371925ff97ae0505a54c9cd9812a6b8d861cd87530c570efbdf760
@@ -1,6 +1,7 @@
1
1
  module Looksist
2
2
  module Common
3
- def entity(entity)
3
+ # Careful with the method names, these become instance variables!!
4
+ def __entity__(entity)
4
5
  entity.to_s.gsub('_id', '')
5
6
  end
6
7
  end
data/lib/looksist/core.rb CHANGED
@@ -11,13 +11,13 @@ module Looksist
11
11
  if what.is_a? Array
12
12
  what.each do |method_name|
13
13
  define_method(method_name) do
14
- JSON.parse(Looksist.redis_service.send("#{entity(bucket)}_for", self.send(using).try(:to_s)) || '{}')[method_name.to_s]
14
+ JSON.parse(Looksist.redis_service.send("#{__entity__(bucket)}_for", self.send(using).try(:to_s)) || '{}')[method_name.to_s]
15
15
  end
16
16
  self.lookup_attributes << method_name
17
17
  end
18
18
  else
19
19
  define_method(what) do
20
- Looksist.redis_service.send("#{entity(bucket)}_for", self.send(using).try(:to_s))
20
+ Looksist.redis_service.send("#{__entity__(bucket)}_for", self.send(using).try(:to_s))
21
21
  end
22
22
  self.lookup_attributes << what.to_sym
23
23
  end
@@ -43,14 +43,14 @@ module Looksist
43
43
  def inject_attributes_at(hash_offset, opts)
44
44
  return nil unless hash_offset
45
45
  keys = hash_offset[opts[:using]]
46
- entity_name = entity(opts[:using])
46
+ entity_name = __entity__(opts[:using])
47
47
  values = Looksist.redis_service.send("#{entity_name}_for", keys)
48
48
  hash_offset[opts[:populate]] = values
49
49
  hash_offset
50
50
  end
51
51
 
52
52
  def inject_attributes_for(arry_of_hashes, opts)
53
- entity_name = entity(opts[:using])
53
+ entity_name = __entity__(opts[:using])
54
54
  keys = (arry_of_hashes.collect { |i| i[opts[:using]] }).compact.uniq
55
55
  values = keys.zip(Looksist.redis_service.send("#{entity_name}_for", keys)).to_h
56
56
  arry_of_hashes.each do |elt|
@@ -1,3 +1,3 @@
1
1
  module Lookist
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: looksist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - RC