selections 0.1.14 → 0.2.1
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/CHANGELOG.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
## 0.1
|
1
|
+
## 0.2.1
|
2
|
+
|
3
|
+
* Check the existence of the selections table in `belongs_to_selection` so it is safe to use during rake tasks like db:reset.
|
4
|
+
|
5
|
+
## 0.1.14 (should of been 0.2.0)
|
2
6
|
* https://github.com/nigelr/selections/issues/7 - add selection items as booleans method names to attached model
|
3
7
|
|
4
8
|
## 0.1.13
|
Binary file
|
@@ -26,15 +26,18 @@ module Selections
|
|
26
26
|
def belongs_to_selection(target, options={})
|
27
27
|
belongs_to target, options.merge(:class_name => "Selection")
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
parent
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
29
|
+
# The "selections" table may not exist during certain rake scenarios such as db:migrate or db:reset.
|
30
|
+
if ActiveRecord::Base.connection.table_exists? Selection.table_name
|
31
|
+
prefix = self.name.downcase
|
32
|
+
parent = Selection.where(system_code: "#{prefix}_#{target}").first
|
33
|
+
if parent
|
34
|
+
target_id = "#{target}_id".to_sym
|
35
|
+
parent.children.each do |s|
|
36
|
+
method_name = "#{s.system_code.sub("#{prefix}_", '')}?".to_sym
|
37
|
+
class_eval do
|
38
|
+
define_method method_name do
|
39
|
+
send(target_id) == s.id
|
40
|
+
end
|
38
41
|
end
|
39
42
|
end
|
40
43
|
end
|
data/lib/selections/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selections
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- README.md
|
158
158
|
- Rakefile
|
159
159
|
- lib/generators/selections_scaffold/selections_scaffold_generator.rb
|
160
|
+
- lib/generators/selections_scaffold/templates/.DS_Store
|
160
161
|
- lib/generators/selections_scaffold/templates/_form.html.haml
|
161
162
|
- lib/generators/selections_scaffold/templates/create_selections.rb
|
162
163
|
- lib/generators/selections_scaffold/templates/edit.html.erb
|