mongoid-dsl 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/mongoid-dsl/monkey.rb +13 -19
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d37b0c5bd20a3683ae4c76517067425243b05167
4
- data.tar.gz: a4daa266cce7305dc49cbe06d8e2b58ae18955b0
3
+ metadata.gz: f39e270dbec92926dffe278614230fcc9e404bba
4
+ data.tar.gz: e5239ffcf0fb792376df65b1339a2627d26569f3
5
5
  SHA512:
6
- metadata.gz: 5f40b0a3a3e312ea6826548c6aa0f60f5b91075101672c199014122efcadca90c8b3c4f3b91625781a85003a7fad724bf89097dd75db0665e10b8a7548554f54
7
- data.tar.gz: d24096d26076067c67594216aa4086cbfb5c2bd650d66f114a45ab855203128e7c440f4571cbbe68ae3f7659adae27ef69c0c190df81f62bd2a3c7f4fc9a5564
6
+ metadata.gz: 13aa7bc9b3a32a975714372d7cc5c9bb55ce83525f13723a81afe5260fb5c530317e4596b79279241018137131362ad5a832494e15f4df60b4130c1983653589
7
+ data.tar.gz: 97449c93b223e46603958d97353c8b54bd749972692b3f6d1e50f348d506c875e73e907d0a14b2505101bda0d5a767c68f1b2c9c297909eda44fae0c362243f5
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.3
1
+ 1.0.5
@@ -587,32 +587,30 @@ module Mongoid
587
587
  # convert mongoid name
588
588
  def convert_model_name
589
589
 
590
- unless self.class <= Class || self.class <= String || self.class <= Symbol || self.class <= NilClass
591
- raise ArgumentError, "invalid input, must be Class or String: => #{self.class} (#{self})"
590
+ unless self.class <= ::Class || self.class <= ::String || self.class <= ::Symbol || self.class <= ::NilClass
591
+ return super;# raise ArgumentError, "invalid input, must be Class or String: => #{self.class} (#{self})"
592
592
  end
593
593
 
594
- if self.class <= NilClass
594
+ if self.class <= ::NilClass
595
595
  return nil
596
596
  end
597
597
 
598
- case self.class.to_s
598
+ case true
599
599
 
600
- when "Class"
600
+ when self.class == ::Class
601
601
  return self.to_s.split('::').last.underscore
602
602
 
603
- when "String","Symbol"
604
- Mongoid.models.each do |one_model_name|
605
- if self.to_s == one_model_name.to_s.split('::').last.underscore || \
606
- self.to_s == one_model_name.to_s.split('::').last.underscore+('s')
607
-
608
- return one_model_name.to_s.constantize
603
+ when ![ ::Symbol, ::String].select{ |klass|self.class <= klass }.empty?
609
604
 
605
+ Mongoid.models.each do |model_name|
606
+ mongoid_model_name= model_name.mongoid_name
607
+ unless [mongoid_model_name,mongoid_model_name+'s'].select{|mn| self.to_s == mn }.empty?
608
+ return model_name.to_s.constantize
610
609
  end
611
610
  end
612
611
 
613
612
  return self.to_s.split('::').last.underscore
614
613
 
615
-
616
614
  end
617
615
 
618
616
  return nil
@@ -622,18 +620,14 @@ module Mongoid
622
620
  alias :mongoize_name :convert_model_name
623
621
  alias :mongoid_name :convert_model_name
624
622
 
625
- alias :mongoid_name_convert :convert_model_name
626
-
627
623
  end
628
624
 
629
625
  end
630
626
 
631
627
  # for manual include
632
- begin
633
- self.__send__ :include, Mongoid::DSL::Document::Include
634
- def self.included klass
635
- klass.__send__ :extend,Mongoid::DSL::Document::Extend
636
- end
628
+ self.__send__ :include, Mongoid::DSL::Document::Include
629
+ def self.included klass
630
+ klass.__send__ :extend,Mongoid::DSL::Document::Extend
637
631
  end
638
632
 
639
633
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Luzsi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-08 00:00:00.000000000 Z
11
+ date: 2014-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler