my_ancestry 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
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
- @objs.select do
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.each do |obj|
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
@@ -18,5 +18,5 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.name = "my_ancestry"
20
20
  gem.require_paths = ["lib"]
21
- gem.version = "0.0.1"
21
+ gem.version = "0.0.2"
22
22
  end
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.1
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-22 00:00:00.000000000Z
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: