unidom-common 0.4 → 0.5
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.
- checksums.yaml +4 -4
- data/README.md +18 -0
- data/app/models/unidom/common/concerns/model_extension.rb +14 -0
- data/lib/unidom/common/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25ba748b7b6950df973d55ff65080aa52a67f363
|
4
|
+
data.tar.gz: 21dda98526536a16ea2e3845212aa260949ef031
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a356a948f45a855167608561c6a618b25eff250a5dee6a98607be244b3209e9a838ed0260eb8fc146c82d358a856f60fa3dd2ad610592cbae9583304f8688d24
|
7
|
+
data.tar.gz: 7586b6951837272f2aec8bf76d36176add24c86e1319c1192b857cbb83c96dc7239d40cb027993d964511187699eaf46d6a6cb53d537eec6bb9f1000c6cb3db5
|
data/README.md
CHANGED
@@ -42,6 +42,24 @@ team.projects.valid_during('2015-01-01'..'2015-12-31').dead
|
|
42
42
|
Project.included_by([ id_1, id_2 ]).excluded_by id_3
|
43
43
|
```
|
44
44
|
|
45
|
+
## No-SQL Columns
|
46
|
+
```ruby
|
47
|
+
class Project < ActiveRecord::Base
|
48
|
+
|
49
|
+
include Unidom::Common::Concerns::ModelExtension
|
50
|
+
|
51
|
+
validates :creator_comment, allow_blank: true, length: { in: 2..200 }
|
52
|
+
validates :last_updater_comment, allow_blank: true, length: { in: 2..200 }
|
53
|
+
|
54
|
+
notation_column :creator_comment, :last_updater_comment
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
project = Project.new
|
59
|
+
project.creator_comment = 'My first project.' # Stored in project.notation['columns']['creator_comment']
|
60
|
+
project.valid? # true
|
61
|
+
```
|
62
|
+
|
45
63
|
## ActiveRecord Migration Naming Convention
|
46
64
|
### Domain Models (200YMMDDHHMMSS)
|
47
65
|
* unidom-common: 200001DDHHMMSS
|
@@ -125,6 +125,20 @@ module Unidom
|
|
125
125
|
model.respond_to?(:id) ? model.id : model
|
126
126
|
end
|
127
127
|
|
128
|
+
def notation_column(*names)
|
129
|
+
names.each do |name|
|
130
|
+
instance_eval do
|
131
|
+
define_method(name) do
|
132
|
+
notation.try(:[], 'columns').try(:[], name)
|
133
|
+
end
|
134
|
+
define_method("#{name}=") do |value|
|
135
|
+
notation['columns'] ||= {}
|
136
|
+
notation['columns'][name] = value
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
128
142
|
end
|
129
143
|
|
130
144
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unidom-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|