constructor-pages 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -9,8 +9,8 @@ module ConstructorPages
|
|
9
9
|
|
10
10
|
validates_uniqueness_of :code_name, :scope => :template_id
|
11
11
|
|
12
|
-
after_create :
|
13
|
-
after_destroy :
|
12
|
+
after_create :create_page_fields
|
13
|
+
after_destroy :destroy_page_fields
|
14
14
|
|
15
15
|
belongs_to :template
|
16
16
|
|
@@ -29,17 +29,18 @@ module ConstructorPages
|
|
29
29
|
private
|
30
30
|
|
31
31
|
def method_uniqueness
|
32
|
-
if Page.first.respond_to?(code_name
|
32
|
+
if Page.first.respond_to?(code_name) \
|
33
|
+
or Page.first.respond_to?(code_name.pluralize) \
|
33
34
|
or Page.first.respond_to?(code_name.singularize) \
|
34
|
-
or template.self_and_ancestors.map{|t| t.code_name}.include?(code_name.pluralize) \
|
35
|
-
or template.self_and_ancestors.map{|t| t.code_name}.include?(code_name.singularize) \
|
36
|
-
or template.descendants.map{|t| t.code_name}.include?(code_name.pluralize) \
|
37
|
-
or template.descendants.map{|t| t.code_name}.include?(code_name.singularize)
|
35
|
+
or template.self_and_ancestors.map{|t| t.code_name unless t.code_name == code_name}.include?(code_name.pluralize) \
|
36
|
+
or template.self_and_ancestors.map{|t| t.code_name t.code_name == code_name}.include?(code_name.singularize) \
|
37
|
+
or template.descendants.map{|t| t.code_name t.code_name == code_name}.include?(code_name.pluralize) \
|
38
|
+
or template.descendants.map{|t| t.code_name t.code_name == code_name}.include?(code_name.singularize)
|
38
39
|
errors.add(:base, "Такой метод уже используется")
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
|
-
def
|
43
|
+
def create_page_fields
|
43
44
|
self.template.pages.each do |page|
|
44
45
|
"constructor_pages/types/#{type_value}_type".classify.constantize.create(
|
45
46
|
:page_id => page.id,
|
@@ -48,7 +49,7 @@ module ConstructorPages
|
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
51
|
-
def
|
52
|
+
def destroy_page_fields
|
52
53
|
self.template.pages.each do |page|
|
53
54
|
"constructor_pages/types/#{type_value}_type".classify.constantize.destroy_all(
|
54
55
|
:page_id => page.id,
|
@@ -18,10 +18,11 @@ module ConstructorPages
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def method_uniqueness
|
21
|
-
if Page.first.respond_to?(code_name
|
21
|
+
if Page.first.respond_to?(code_name) \
|
22
|
+
or Page.first.respond_to?(code_name.pluralize) \
|
22
23
|
or Page.first.respond_to?(code_name.singularize) \
|
23
|
-
or root.descendants.map{|t| t.code_name}.include?(code_name.pluralize) \
|
24
|
-
or root.descendants.map{|t| t.code_name}.include?(code_name.singularize) \
|
24
|
+
or root.descendants.map{|t| t.code_name unless t.code_name == code_name}.include?(code_name.pluralize) \
|
25
|
+
or root.descendants.map{|t| t.code_name unless t.code_name == code_name}.include?(code_name.singularize) \
|
25
26
|
|
26
27
|
errors.add(:base, "Такой метод уже используется")
|
27
28
|
end
|
data/constructor-pages.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: constructor-pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.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: 2013-
|
12
|
+
date: 2013-06-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dragonfly
|