e9_rails 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,7 +11,6 @@ module E9Rails::ActiveRecord
11
11
  def attr_like_scope_condition(attr_name, string, opts = {})
12
12
  matcher = opts.delete(:matcher) || "%%%s%%"
13
13
  arel_table[attr_name].matches(matcher % string)
14
-
15
14
  end
16
15
 
17
16
  def any_attrs_like_scope_conditions(*args)
@@ -28,17 +28,32 @@ module E9Rails::ActiveRecord
28
28
  end
29
29
 
30
30
  def options=(hash={})
31
- write_attribute(options_column, hash.stringify_keys)
31
+ ensuring_method_attributes do
32
+ write_attribute(options_column, hash.stringify_keys)
33
+ end
32
34
  end
33
35
 
34
36
  def options
35
- opts = read_attribute(options_column) || {}
36
- opts.reverse_merge! Hash[options_parameters.map(&:to_s).zip([nil])]
37
- options_class.new(opts, self)
37
+ ensuring_method_attributes do
38
+ opts = read_attribute(options_column) || {}
39
+ opts.reverse_merge! Hash[options_parameters.map(&:to_s).zip([nil])]
40
+ options_class.new(opts, self)
41
+ end
38
42
  end
39
43
 
40
44
  protected
41
45
 
46
+ def ensuring_method_attributes
47
+ yield
48
+ rescue
49
+ if !self.class.attribute_methods_generated?
50
+ self.class.define_attribute_methods
51
+ retry
52
+ else
53
+ raise $!
54
+ end
55
+ end
56
+
42
57
  module ClassMethods
43
58
  def define_method_attribute_with_inheritable_options(attr_name)
44
59
  initialize_inheritable_options
@@ -1,3 +1,3 @@
1
1
  module E9Rails
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: e9_rails
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.13
5
+ version: 0.0.14
6
6
  platform: ruby
7
7
  authors:
8
8
  - Travis Cox
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-16 00:00:00 -04:00
13
+ date: 2011-05-18 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency