kelredd-useful 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/useful/rails_extensions/environment_tests.rb +60 -0
- data/lib/useful/rails_extensions.rb +3 -0
- data/lib/useful/ruby_extensions/false_class.rb +1 -0
- data/lib/useful/ruby_extensions/hash.rb +1 -1
- data/lib/useful/ruby_extensions/true_class.rb +1 -0
- data/lib/useful/version.rb +1 -1
- metadata +4 -1
@@ -0,0 +1,60 @@
|
|
1
|
+
module Useful
|
2
|
+
module RailsExtensions
|
3
|
+
module EnvironmentTests
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
|
7
|
+
def production?
|
8
|
+
RAILS_ENV == 'production'
|
9
|
+
end
|
10
|
+
|
11
|
+
def development?
|
12
|
+
RAILS_ENV == 'development'
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
module InstanceMethods
|
18
|
+
|
19
|
+
def production?
|
20
|
+
self.class.production?
|
21
|
+
end
|
22
|
+
|
23
|
+
def development?
|
24
|
+
self.class.development?
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.included(receiver)
|
30
|
+
receiver.extend ClassMethods
|
31
|
+
receiver.send :include, InstanceMethods
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module ActiveRecord
|
39
|
+
class Base
|
40
|
+
include Useful::RailsExtensions::EnvironmentTests
|
41
|
+
end
|
42
|
+
class Observer
|
43
|
+
include Useful::RailsExtensions::EnvironmentTests
|
44
|
+
end
|
45
|
+
end
|
46
|
+
module ActionController
|
47
|
+
class Base
|
48
|
+
include Useful::RailsExtensions::EnvironmentTests
|
49
|
+
end
|
50
|
+
end
|
51
|
+
module ActionView
|
52
|
+
class Base
|
53
|
+
include Useful::RailsExtensions::EnvironmentTests
|
54
|
+
end
|
55
|
+
end
|
56
|
+
module ActionMailer
|
57
|
+
class Base
|
58
|
+
include Useful::RailsExtensions::EnvironmentTests
|
59
|
+
end
|
60
|
+
end
|
@@ -42,7 +42,7 @@ module Useful
|
|
42
42
|
# Determines if a value exists for the provided key(s). Allows searching in nested hashes
|
43
43
|
def check_value?(*keys)
|
44
44
|
val = self[keys.first] || self[keys.first.to_s]
|
45
|
-
val = self[keys.first.to_s.intern] unless val || keys.first.kind_of?(Symbol)
|
45
|
+
val = self[keys.first.to_s.intern] unless val || keys.first.to_s.empty? || keys.first.kind_of?(Symbol)
|
46
46
|
return val.check_value?(*keys[1..-1]) if val.kind_of?(Hash) && keys.length > 1
|
47
47
|
return true if val && !val.empty?
|
48
48
|
false
|
data/lib/useful/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kelredd-useful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelredd
|
@@ -25,6 +25,9 @@ files:
|
|
25
25
|
- README.rdoc
|
26
26
|
- Rakefile
|
27
27
|
- lib/useful
|
28
|
+
- lib/useful/rails_extensions
|
29
|
+
- lib/useful/rails_extensions/environment_tests.rb
|
30
|
+
- lib/useful/rails_extensions.rb
|
28
31
|
- lib/useful/ruby_extensions
|
29
32
|
- lib/useful/ruby_extensions/array.rb
|
30
33
|
- lib/useful/ruby_extensions/date.rb
|