indexable_attribute 0.0.5 → 0.0.8
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 +8 -8
- data/lib/indexable_attribute.rb +22 -4
- data/lib/indexable_attribute/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzY3NTAwMzZlOTE0YmZhZTg4YmRkMjE5Zjk2YzRmYTFjMjE1NDRiYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDlhMTVkOWMxZjQ1Mzg2ZWQyODkxODZjNjRhOTQ1ZWI3MmUyNjdiZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDJmMjdhMGIwYTc4YWJjZDY5YTVjNDU0ZTIyMjAwMzA0OWYwYTAzMmJhMzZm
|
10
|
+
N2UwYWI3ZmIzM2M5MDY5MjllNGQyMTNlZjcxMDU2OGU4YTliNzJlODBlYWIz
|
11
|
+
MWZiYWE4ZGFmZjZhOTllNTZiMmEwZGE0ZTc1MGM4ZjcwYzZmYWU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTIxMzBhZmYzOWFiYzViMDJhYmJjZTc5NjM3NTQ3ZDJmMjE0MmE5ODUyOTE4
|
14
|
+
OTNlYTBiODk4MWI1YTA3NWY5ZGQ0ZTIxNmQ2NDliZGE2ZjFlNTI1OWEwNDAw
|
15
|
+
MzJlNDc4ZjA4Zjg3ZWI3MWIzMzkyNzBiOTY3NzA4YWM1NGM5YjM=
|
data/lib/indexable_attribute.rb
CHANGED
@@ -5,10 +5,28 @@ require "active_record"
|
|
5
5
|
module IndexableAttribute
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
module ClassMethods
|
8
|
-
def indexable_attribute(
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
def indexable_attribute(attr_acc, attr_list, attr_name=nil)
|
9
|
+
attr_name = attr_acc unless attr_name
|
10
|
+
unless @create_overriden
|
11
|
+
def self.create(*lst)
|
12
|
+
objs = []
|
13
|
+
lst.each do |item|
|
14
|
+
obj = self.new
|
15
|
+
item.each do |k,v|
|
16
|
+
class_eval %Q{
|
17
|
+
obj.#{k} = v
|
18
|
+
}
|
19
|
+
end
|
20
|
+
obj.save
|
21
|
+
objs.push(obj)
|
22
|
+
end
|
23
|
+
objs.count > 1 ? objs : objs[0]
|
24
|
+
end
|
25
|
+
@create_overriden = true
|
26
|
+
end
|
27
|
+
_CNST = attr_acc.to_s.upcase
|
28
|
+
_ATTR = attr_acc.to_s.downcase
|
29
|
+
_ATTR_ID = attr_name.to_s.downcase
|
12
30
|
class_eval %Q{
|
13
31
|
#{_CNST} = #{attr_list.map { |i| i.to_sym }.to_s}
|
14
32
|
|