has_handle_fallback 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/has_handle_fallback.rb +1 -19
  3. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -24,13 +24,10 @@ module HasHandleFallback
24
24
  end
25
25
 
26
26
  module ActiveRecordBaseMethods
27
- def has_handle_fallback(*args)
27
+ def has_handle_fallback(fallback_column, options = {})
28
28
  include InstanceMethods
29
29
  extend ClassMethods
30
30
 
31
- fallback_column = args.first.respond_to?(:[]) ? nil : args.shift.to_s
32
- options = args.shift || {}
33
-
34
31
  class_eval do
35
32
  cattr_accessor :has_handle_fallback_options
36
33
  self.has_handle_fallback_options = {}
@@ -59,23 +56,8 @@ module HasHandleFallback
59
56
  end
60
57
 
61
58
  module InstanceMethods
62
- def fallback_handle_is_valid?
63
- fallback_column = self.class.has_handle_fallback_options[:fallback_column]
64
- # only check if we need to actually generate a fallback
65
- if handle.blank? and fallback_column.present?
66
- handle_fallback =~ HasHandleFallback::REGEXP and HasHandleFallback::LENGTH_RANGE.include?(handle_fallback.length)
67
- else
68
- true
69
- end
70
- end
71
-
72
59
  def handle_is_valid
73
60
  raw = read_attribute self.class.has_handle_fallback_options[:handle_column]
74
-
75
- # inline check to make sure the handle_fallback method works
76
- unless fallback_handle_is_valid?
77
- raise "Dear Developer: your handle_fallback method is not generating valid handles (generated '#{handle_fallback}' for '#{raw}')"
78
- end
79
61
 
80
62
  # allow nils but not blanks
81
63
  if raw.blank? and (!raw.nil? or has_handle_fallback_options[:required])
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_handle_fallback
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Seamus Abshere
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-29 00:00:00 -04:00
18
+ date: 2010-06-30 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency