zh_kostev_ext 0.1.1 → 0.1.2
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module
|
|
1
|
+
module ControllerExtensions
|
|
2
2
|
module GeneralMethods
|
|
3
3
|
def self.included(base)
|
|
4
4
|
base.class_eval do
|
|
@@ -21,9 +21,9 @@ module ControllerModules
|
|
|
21
21
|
def find_resource_or_404
|
|
22
22
|
model_name = defined?(self.class::DB_MODEL) ? self.class::DB_MODEL : controller_name.singularize
|
|
23
23
|
model_to_find = defined?(self.class::DB_SCOPE) ? model_name.to_s.classify.constantize.send(self.class::DB_SCOPE) : model_name.to_s.classify.constantize
|
|
24
|
-
|
|
25
|
-
instance_variable_set("@#{model_name.to_s.underscore}",
|
|
26
|
-
|
|
24
|
+
begin
|
|
25
|
+
instance_variable_set("@#{model_name.to_s.underscore}", model_to_find.find(params[:id]))
|
|
26
|
+
rescue
|
|
27
27
|
redirect_to '/404'
|
|
28
28
|
end
|
|
29
29
|
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module RubyClassesExtensions
|
|
2
|
+
module HashExtensions
|
|
3
|
+
def self.included(base)
|
|
4
|
+
base.class_eval do
|
|
5
|
+
#return new Hash. This hash return humanized value of key(except moments when key has set another value)
|
|
6
|
+
#example
|
|
7
|
+
# a = Hash.humanized
|
|
8
|
+
# a[:vladimir] = 'Vlad'
|
|
9
|
+
#
|
|
10
|
+
# a[:misha] will return 'Misha'
|
|
11
|
+
# a[:vladimir] will return 'Vlad'(because this value set manually)
|
|
12
|
+
# f["fred_loves_new_cars"] will return "Fred loves new cars"
|
|
13
|
+
def self.humanized
|
|
14
|
+
self.new{|hash,k| hash[k] = k.to_s.humanize}
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/zh_kostev_ext.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zh_kostev_ext
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
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: 2012-
|
|
12
|
+
date: 2012-10-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: shoulda
|
|
@@ -99,7 +99,8 @@ extra_rdoc_files:
|
|
|
99
99
|
- LICENSE.txt
|
|
100
100
|
- README.rdoc
|
|
101
101
|
files:
|
|
102
|
-
- lib/
|
|
102
|
+
- lib/controller_extensions/general_methods.rb
|
|
103
|
+
- lib/ruby_classes_extensions/hash_extensions.rb
|
|
103
104
|
- lib/zh_kostev_ext.rb
|
|
104
105
|
- LICENSE.txt
|
|
105
106
|
- README.rdoc
|
|
@@ -118,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
118
119
|
version: '0'
|
|
119
120
|
segments:
|
|
120
121
|
- 0
|
|
121
|
-
hash:
|
|
122
|
+
hash: 1061715859
|
|
122
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
124
|
none: false
|
|
124
125
|
requirements:
|