property 2.1.2 → 2.2.0
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.
- data/History.txt +5 -0
- data/lib/property/attribute.rb +1 -1
- data/lib/property/column.rb +4 -1
- data/lib/property/index.rb +2 -2
- data/lib/property/role_module.rb +1 -1
- data/lib/property/stored_column.rb +5 -0
- data/lib/property/stored_role.rb +2 -3
- data/lib/property/version.rb +1 -1
- data/property.gemspec +77 -80
- data/test/test_helper.rb +1 -0
- metadata +8 -9
- data/.gitignore +0 -5
data/History.txt
CHANGED
data/lib/property/attribute.rb
CHANGED
data/lib/property/column.rb
CHANGED
@@ -59,7 +59,9 @@ module Property
|
|
59
59
|
alias ptype type
|
60
60
|
|
61
61
|
def type_cast(value)
|
62
|
-
if
|
62
|
+
if @caster && val = @caster.type_cast(value)
|
63
|
+
val
|
64
|
+
elsif type == :string
|
63
65
|
value = value.to_s
|
64
66
|
value.blank? ? nil : value
|
65
67
|
elsif @klass
|
@@ -78,6 +80,7 @@ module Property
|
|
78
80
|
def extract_property_options(options)
|
79
81
|
@index = options.delete(:index) || options.delete(:indexed)
|
80
82
|
@role = options.delete(:role)
|
83
|
+
@caster= options.delete(:orig)
|
81
84
|
if @index == true
|
82
85
|
@index = (options.delete(:index_group) || ptype).to_s
|
83
86
|
elsif @index.kind_of?(Proc)
|
data/lib/property/index.rb
CHANGED
@@ -186,7 +186,7 @@ module Property
|
|
186
186
|
cur_indices.merge!(proc.call(self))
|
187
187
|
end
|
188
188
|
end
|
189
|
-
|
189
|
+
|
190
190
|
if group_name.kind_of?(Class)
|
191
191
|
# Use a custom indexer
|
192
192
|
group_name.set_property_index(self, cur_indices)
|
@@ -200,7 +200,7 @@ module Property
|
|
200
200
|
new_keys = cur_keys - old_keys
|
201
201
|
del_keys = old_keys - cur_keys
|
202
202
|
upd_keys = cur_keys & old_keys
|
203
|
-
|
203
|
+
|
204
204
|
upd_keys.each do |key|
|
205
205
|
value = cur_indices[key]
|
206
206
|
if value.blank?
|
data/lib/property/role_module.rb
CHANGED
@@ -101,7 +101,7 @@ module Property
|
|
101
101
|
|
102
102
|
def inspect
|
103
103
|
# "#<#{self.class}:#{sprintf("0x%x", object_id)} #{@name.inspect} @klass = #{@klass.inspect} @defined_columns = #{@defined_columns.inspect}>"
|
104
|
-
"#<#{self.class}
|
104
|
+
"#<#{self.class}:'#{name}' #{defined_columns.keys.join(', ')}>"
|
105
105
|
end
|
106
106
|
|
107
107
|
# List all property columns defined for this role
|
data/lib/property/stored_role.rb
CHANGED
@@ -22,7 +22,7 @@ module Property
|
|
22
22
|
base.class_eval do
|
23
23
|
after_save :update_columns
|
24
24
|
validates_presence_of :name
|
25
|
-
|
25
|
+
|
26
26
|
extend ClassMethods
|
27
27
|
|
28
28
|
def self.new(arg, &block)
|
@@ -67,7 +67,7 @@ module Property
|
|
67
67
|
@original_columns = {}
|
68
68
|
stored_columns.each do |column|
|
69
69
|
@original_columns[column.name] = column
|
70
|
-
add_column(Property::Column.new(column.name, column.default, column.ptype, column.options.merge(:role => self)))
|
70
|
+
add_column(Property::Column.new(column.name, column.default, column.ptype, column.options.merge(:role => self, :orig => column)))
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -85,7 +85,6 @@ module Property
|
|
85
85
|
# deleted_columns = stored_column_names - defined_column_names
|
86
86
|
|
87
87
|
new_columns.each do |name|
|
88
|
-
ActiveRecord::Base.logger.warn "Creating #{name} column"
|
89
88
|
stored_columns.create(:name => name, :ptype => columns[name].type.to_s)
|
90
89
|
end
|
91
90
|
|
data/lib/property/version.rb
CHANGED
data/property.gemspec
CHANGED
@@ -1,108 +1,105 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{property}
|
8
|
-
s.version = "2.
|
8
|
+
s.version = "2.2.0"
|
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{
|
12
|
+
s.date = %q{2011-06-06}
|
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 = [
|
16
16
|
"README.rdoc"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
".
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
"test/unit/serialization/yaml_test.rb"
|
19
|
+
"History.txt",
|
20
|
+
"MIT-LICENSE",
|
21
|
+
"README.rdoc",
|
22
|
+
"Rakefile",
|
23
|
+
"generators/property/property_generator.rb",
|
24
|
+
"lib/property.rb",
|
25
|
+
"lib/property/attribute.rb",
|
26
|
+
"lib/property/base.rb",
|
27
|
+
"lib/property/column.rb",
|
28
|
+
"lib/property/core_ext/time.rb",
|
29
|
+
"lib/property/db.rb",
|
30
|
+
"lib/property/declaration.rb",
|
31
|
+
"lib/property/dirty.rb",
|
32
|
+
"lib/property/error.rb",
|
33
|
+
"lib/property/index.rb",
|
34
|
+
"lib/property/properties.rb",
|
35
|
+
"lib/property/redefined_method_error.rb",
|
36
|
+
"lib/property/redefined_property_error.rb",
|
37
|
+
"lib/property/role.rb",
|
38
|
+
"lib/property/role_module.rb",
|
39
|
+
"lib/property/schema.rb",
|
40
|
+
"lib/property/schema_module.rb",
|
41
|
+
"lib/property/serialization/json.rb",
|
42
|
+
"lib/property/serialization/marshal.rb",
|
43
|
+
"lib/property/serialization/yaml.rb",
|
44
|
+
"lib/property/stored_column.rb",
|
45
|
+
"lib/property/stored_role.rb",
|
46
|
+
"lib/property/stored_schema.rb",
|
47
|
+
"lib/property/version.rb",
|
48
|
+
"property.gemspec",
|
49
|
+
"test/database.rb",
|
50
|
+
"test/fixtures.rb",
|
51
|
+
"test/shoulda_macros/index.rb",
|
52
|
+
"test/shoulda_macros/role.rb",
|
53
|
+
"test/shoulda_macros/serialization.rb",
|
54
|
+
"test/test_helper.rb",
|
55
|
+
"test/unit/property/attribute_test.rb",
|
56
|
+
"test/unit/property/base_test.rb",
|
57
|
+
"test/unit/property/column_test.rb",
|
58
|
+
"test/unit/property/declaration_test.rb",
|
59
|
+
"test/unit/property/dirty_test.rb",
|
60
|
+
"test/unit/property/index_complex_test.rb",
|
61
|
+
"test/unit/property/index_custom_test.rb",
|
62
|
+
"test/unit/property/index_field_test.rb",
|
63
|
+
"test/unit/property/index_foreign_test.rb",
|
64
|
+
"test/unit/property/index_simple_test.rb",
|
65
|
+
"test/unit/property/role_test.rb",
|
66
|
+
"test/unit/property/stored_role_test.rb",
|
67
|
+
"test/unit/property/validation_test.rb",
|
68
|
+
"test/unit/serialization/json_test.rb",
|
69
|
+
"test/unit/serialization/marshal_test.rb",
|
70
|
+
"test/unit/serialization/yaml_test.rb"
|
72
71
|
]
|
73
72
|
s.homepage = %q{http://zenadmin.org/635}
|
74
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
75
73
|
s.require_paths = ["lib"]
|
76
74
|
s.rubyforge_project = %q{property}
|
77
|
-
s.rubygems_version = %q{1.
|
75
|
+
s.rubygems_version = %q{1.6.1}
|
78
76
|
s.summary = %q{model properties wrap into a single database column}
|
79
77
|
s.test_files = [
|
80
78
|
"test/database.rb",
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
79
|
+
"test/fixtures.rb",
|
80
|
+
"test/shoulda_macros/index.rb",
|
81
|
+
"test/shoulda_macros/role.rb",
|
82
|
+
"test/shoulda_macros/serialization.rb",
|
83
|
+
"test/test_helper.rb",
|
84
|
+
"test/unit/property/attribute_test.rb",
|
85
|
+
"test/unit/property/base_test.rb",
|
86
|
+
"test/unit/property/column_test.rb",
|
87
|
+
"test/unit/property/declaration_test.rb",
|
88
|
+
"test/unit/property/dirty_test.rb",
|
89
|
+
"test/unit/property/index_complex_test.rb",
|
90
|
+
"test/unit/property/index_custom_test.rb",
|
91
|
+
"test/unit/property/index_field_test.rb",
|
92
|
+
"test/unit/property/index_foreign_test.rb",
|
93
|
+
"test/unit/property/index_simple_test.rb",
|
94
|
+
"test/unit/property/role_test.rb",
|
95
|
+
"test/unit/property/stored_role_test.rb",
|
96
|
+
"test/unit/property/validation_test.rb",
|
97
|
+
"test/unit/serialization/json_test.rb",
|
98
|
+
"test/unit/serialization/marshal_test.rb",
|
99
|
+
"test/unit/serialization/yaml_test.rb"
|
102
100
|
]
|
103
101
|
|
104
102
|
if s.respond_to? :specification_version then
|
105
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
106
103
|
s.specification_version = 3
|
107
104
|
|
108
105
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
data/test/test_helper.rb
CHANGED
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:
|
5
|
-
prerelease:
|
4
|
+
hash: 7
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
- 1
|
9
8
|
- 2
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 2.2.0
|
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:
|
19
|
+
date: 2011-06-06 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -56,7 +56,6 @@ extensions: []
|
|
56
56
|
extra_rdoc_files:
|
57
57
|
- README.rdoc
|
58
58
|
files:
|
59
|
-
- .gitignore
|
60
59
|
- History.txt
|
61
60
|
- MIT-LICENSE
|
62
61
|
- README.rdoc
|
@@ -114,8 +113,8 @@ homepage: http://zenadmin.org/635
|
|
114
113
|
licenses: []
|
115
114
|
|
116
115
|
post_install_message:
|
117
|
-
rdoc_options:
|
118
|
-
|
116
|
+
rdoc_options: []
|
117
|
+
|
119
118
|
require_paths:
|
120
119
|
- lib
|
121
120
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -139,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
138
|
requirements: []
|
140
139
|
|
141
140
|
rubyforge_project: property
|
142
|
-
rubygems_version: 1.
|
141
|
+
rubygems_version: 1.6.1
|
143
142
|
signing_key:
|
144
143
|
specification_version: 3
|
145
144
|
summary: model properties wrap into a single database column
|