e9_rails 0.0.8 → 0.0.9
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.
@@ -7,7 +7,8 @@ module E9Rails::ActiveRecord
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
included do
|
10
|
-
|
10
|
+
class_inheritable_accessor :options_column
|
11
|
+
self.options_column = :options
|
11
12
|
|
12
13
|
class_inheritable_accessor :options_parameters
|
13
14
|
self.options_parameters = []
|
@@ -19,16 +20,27 @@ module E9Rails::ActiveRecord
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def options=(hash={})
|
22
|
-
|
23
|
+
_serialize_inheritable_options_column unless _inheritable_options_column_serialized?
|
24
|
+
write_attribute(options_column, hash.stringify_keys)
|
23
25
|
end
|
24
26
|
|
25
27
|
def options
|
26
|
-
|
28
|
+
_serialize_inheritable_options_column unless _inheritable_options_column_serialized?
|
29
|
+
opts = read_attribute(options_column) || {}
|
27
30
|
opts.reverse_merge! Hash[options_parameters.map(&:to_s).zip([nil])]
|
28
|
-
|
29
31
|
options_class.new(opts, self)
|
30
32
|
end
|
31
33
|
|
34
|
+
protected
|
35
|
+
|
36
|
+
def _serialize_inheritable_options_column
|
37
|
+
self.class.serialized_attributes[options_column.to_s] = Hash
|
38
|
+
end
|
39
|
+
|
40
|
+
def _inheritable_options_column_serialized?
|
41
|
+
self.class.serialized_attributes[options_column.to_s].present?
|
42
|
+
end
|
43
|
+
|
32
44
|
class Options < HashWithIndifferentAccess
|
33
45
|
extend ActiveModel::Naming
|
34
46
|
extend ActiveModel::Translation
|
data/lib/e9_rails/version.rb
CHANGED
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.
|
5
|
+
version: 0.0.9
|
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-04-
|
13
|
+
date: 2011-04-25 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|