my_ancestry 0.0.1 → 0.0.2
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/README.md +3 -1
- data/lib/my_ancestry.rb +5 -7
- data/my_ancestry.gemspec +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -54,4 +54,6 @@ Or install it yourself as:
|
|
54
54
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
55
55
|
4. Push to the branch (`git push origin my-new-feature`)
|
56
56
|
5. Create new Pull Request
|
57
|
-
6. Execure the "THE BEER-WARE LICENSE".
|
57
|
+
6. Execure the "THE BEER-WARE LICENSE".
|
58
|
+
|
59
|
+
#tnks for Digaoddc (https://github.com/digaoddc/)
|
data/lib/my_ancestry.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
class TypeException < Exception ;end
|
2
2
|
class MyAncestry
|
3
3
|
|
4
|
+
attr_reader :objs
|
5
|
+
|
4
6
|
def initialize(objs, options={})
|
5
7
|
validate_objs(objs)
|
6
8
|
@objs = objs
|
@@ -18,10 +20,8 @@ class MyAncestry
|
|
18
20
|
@objs
|
19
21
|
end
|
20
22
|
|
21
|
-
def search
|
22
|
-
|
23
|
-
yield
|
24
|
-
end
|
23
|
+
def search(&blk)
|
24
|
+
objs.select(&blk)
|
25
25
|
end
|
26
26
|
|
27
27
|
#Search parent by id of child
|
@@ -50,9 +50,7 @@ class MyAncestry
|
|
50
50
|
|
51
51
|
def validate_objs(objs)
|
52
52
|
first_class_name = objs.first.class.name
|
53
|
-
objs.
|
54
|
-
raise TypeException.new "The list of objets must be a single type" unless first_class_name == obj.class.name
|
55
|
-
end
|
53
|
+
raise TypeException.new "The list of objets must be a single type" if objs.any? { |obj| obj.class.to_s != first_class_name}
|
56
54
|
end
|
57
55
|
|
58
56
|
private
|
data/my_ancestry.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_ancestry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-24 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! "\n Make search of objects parents/childrem/brothers"
|
15
15
|
email:
|