has_handle_fallback 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -19,4 +19,4 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
- test/test.sqlite3
22
+ test/test.sqlite3
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.3
@@ -6,8 +6,8 @@ module HasHandleFallback
6
6
  RECORD_ID_REGEXP = /\A\d+\z/
7
7
 
8
8
  def self.str2handle(str)
9
- str = str.gsub ANTI_REGEXP, ''
10
- str << ('_' * LENGTH_RANGE.min - str.length) unless LENGTH_RANGE.include?(str.length)
9
+ str = str.to_s.gsub ANTI_REGEXP, ''
10
+ str << ('_' * (LENGTH_RANGE.min - str.length)) unless LENGTH_RANGE.include?(str.length)
11
11
  str
12
12
  end
13
13
 
@@ -74,7 +74,7 @@ module HasHandleFallback
74
74
  end
75
75
 
76
76
  # validates_uniqueness_of :handle, :case_sensitive => false, :allow_nil => true
77
- if self.class.exists? [ "LOWER(#{self.class.quoted_table_name}.`#{self.class.has_handle_fallback_options[:handle_column]}`) = ?", raw.downcase ]
77
+ if self.class.exists? [ "#{self.class.quoted_table_name}.`#{self.class.primary_key}` <> ? AND LOWER(#{self.class.quoted_table_name}.`#{self.class.has_handle_fallback_options[:handle_column]}`) = ?", id, raw.downcase ]
78
78
  errors.add self.class.has_handle_fallback_options[:handle_column], "isn't unique"
79
79
  end
80
80
  end
@@ -86,7 +86,7 @@ module HasHandleFallback
86
86
 
87
87
  def handle_fallback
88
88
  fallback = read_attribute self.class.has_handle_fallback_options[:fallback_column]
89
- fallback = fallback.split('@').first if fallback.include? '@'
89
+ fallback = fallback.split('@').first if fallback.to_s.include? '@'
90
90
  HasHandleFallback.str2handle fallback
91
91
  end
92
92
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_handle_fallback
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seamus Abshere