property 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -1
- data/lib/property/column.rb +1 -1
- data/lib/property/dirty.rb +1 -1
- data/lib/property/properties.rb +12 -0
- data/lib/property/version.rb +1 -1
- data/property.gemspec +2 -2
- metadata +4 -4
data/History.txt
CHANGED
data/lib/property/column.rb
CHANGED
@@ -6,7 +6,7 @@ module Property
|
|
6
6
|
# such as name, type and options. It is also used to typecast from strings to
|
7
7
|
# the proper type (date, integer, float, etc).
|
8
8
|
class Column < ::ActiveRecord::ConnectionAdapters::Column
|
9
|
-
attr_accessor :index
|
9
|
+
attr_accessor :index, :caster
|
10
10
|
|
11
11
|
SAFE_NAMES_REGEXP = %r{\A[a-zA-Z_]+\Z}
|
12
12
|
|
data/lib/property/dirty.rb
CHANGED
data/lib/property/properties.rb
CHANGED
@@ -33,6 +33,18 @@ module Property
|
|
33
33
|
else
|
34
34
|
delete(key)
|
35
35
|
end
|
36
|
+
elsif value.kind_of?(Hash) && column.klass <= Hash && column.caster.respond_to?(:merge_hash)
|
37
|
+
# We *MUST* duplicate hash here or Dirty will not function correctly.
|
38
|
+
value = column.caster.merge_hash(self[key].dup, value)
|
39
|
+
if value.blank?
|
40
|
+
if default = column.default_for(@owner)
|
41
|
+
super(key, default)
|
42
|
+
else
|
43
|
+
delete(key)
|
44
|
+
end
|
45
|
+
else
|
46
|
+
super(key, value)
|
47
|
+
end
|
36
48
|
else
|
37
49
|
super(key, column.type_cast(value))
|
38
50
|
end
|
data/lib/property/version.rb
CHANGED
data/property.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{property}
|
8
|
-
s.version = "2.3.
|
8
|
+
s.version = "2.3.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Renaud Kern", "Gaspard Bucher"]
|
12
|
-
s.date = %q{2012-
|
12
|
+
s.date = %q{2012-07-02}
|
13
13
|
s.description = %q{Wrap model properties into a single database column and declare properties from within the model.}
|
14
14
|
s.email = %q{gaspard@teti.ch}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: property
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 2.3.
|
9
|
+
- 1
|
10
|
+
version: 2.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Renaud Kern
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-
|
19
|
+
date: 2012-07-02 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|