unidom-common 0.7 → 0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b96f049bc613e7a49dddeb8822ca4910070ab5f8
4
- data.tar.gz: 684e39544b8284dc7ac5910b8c55a94aa2223b81
3
+ metadata.gz: c8de80c2c271dd2a9dc39296d31306f278a6d7d8
4
+ data.tar.gz: 3384250750c545fcacbc879f9d3879484a332636
5
5
  SHA512:
6
- metadata.gz: 5fd975d280c9992f6b82e0d1ed47d35ac3d28ae46d525771e3e30102451564ca9e2cd1ed8a8be47c6e662105718477ff0cb659d1d7df001f4aa911b4f38bd57b
7
- data.tar.gz: 327407dd19b9d2f96161fb995b01980e8fa87db212653c63b276f0663214c36dbcae02d381f9387822a501ea111f1fd663e63adc7e528906c88cdf64288ac77d
6
+ metadata.gz: aeefa2083c70863553b8bf1d3b4d4ffe980c7c9bbfa033420693ac4c1733fc16a92284f797a891bdf922896607a7c680bebcae1fb4140c9eccfcc3bd48ab4243
7
+ data.tar.gz: d3cdbae24ba9751a7b13badd2bdaeff291cde8d61624af31ffb563cb81a48b7cad5cd44b1a2961828c5eec47a07b2ddf9e61588a8e7da23e618ec03ecb8c578e
data/README.md CHANGED
@@ -19,6 +19,7 @@ gem 'unidom-common'
19
19
  ```shell
20
20
  rake db:migrate
21
21
  ```
22
+ The migration versions starts with 200001.
22
23
  The migration enabled the PostgreSQL uuid-ossp extension.
23
24
 
24
25
  ## Include Concern in Models
@@ -59,6 +60,7 @@ class Project < ActiveRecord::Base
59
60
  include Unidom::Common::Concerns::ModelExtension
60
61
 
61
62
  notation_column :creator_comment, :last_updater_comment
63
+ notation_boolean_column :enabled
62
64
 
63
65
  validates :creator_comment, allow_blank: true, length: { in: 2..200 }
64
66
  validates :last_updater_comment, allow_blank: true, length: { in: 2..200 }
@@ -71,6 +73,9 @@ project.valid? # true
71
73
 
72
74
  Project.notation_column_where(:creator_comment, :like, 'first') # Fuzzy search the creator_comment column
73
75
  Project.notation_column_where(:creator_comment, '=', 'My first project.')
76
+
77
+ project.enabled = true
78
+ project.enabled? # true
74
79
  ```
75
80
 
76
81
  ## ActiveRecord Migration Naming Convention
@@ -156,6 +156,21 @@ module Unidom
156
156
  end
157
157
  end
158
158
 
159
+ def notation_boolean_column(*names)
160
+ names.each do |name|
161
+ name = name.to_s
162
+ instance_eval do
163
+ define_method("#{name}?") do
164
+ notation.try(:[], 'columns').try(:[], name)
165
+ end
166
+ define_method("#{name}=") do |value|
167
+ notation['columns'] ||= {}
168
+ notation['columns'][name] = value
169
+ end
170
+ end
171
+ end
172
+ end
173
+
159
174
  end
160
175
 
161
176
  end
@@ -1,5 +1,5 @@
1
1
  module Unidom
2
2
  module Common
3
- VERSION = '0.7'.freeze
3
+ VERSION = '0.8'.freeze
4
4
  end
5
5
  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.7'
4
+ version: '0.8'
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-30 00:00:00.000000000 Z
11
+ date: 2016-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails