ruby-rails-extensions 2.1.0.pre.rc.8 → 2.1.0.pre.rc.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4924afbe4a7a485556e5b773fadd2f3119168faf0af0fd7963e6d30dcd38fb49
4
- data.tar.gz: 0a3c69358e4895b12e65034e47d06fbbe417b8877014b256c55c2a9bbcc84eda
3
+ metadata.gz: a2f8208756fad0f3e2d3467fe56d7f299ee20d04db7290e6079e2b5f60b9fb2f
4
+ data.tar.gz: 62d873c62e3d3cfcba37d70c63565d83bf84887d30285f23cf25ca62912cfdb9
5
5
  SHA512:
6
- metadata.gz: b6df635f383c654e4966942bc01a0200e80a1e7f49013a60afa1ebb5a7132a2e73e80d540a64baaaf85b91b57d61191027244851c895c5027f857f8774d2fe20
7
- data.tar.gz: 3973b6bbb600e313b21f3963f848639152b342e4174340bccfac418f26a011fa2107f4d1d4a1c84edad5892e7d184a977badb47fbd17a3f44fa8e7722c107cc3
6
+ metadata.gz: fc3318c549ddeb4cdaa3f7d393dfa26a0d1ff6ad41c0f375fc282e97d5fadfa0d8d82b7518b5ec1624e7272c51a95f536e79d142d1042745ef5bc8e7edae5c04
7
+ data.tar.gz: 7d1fd81b3578daf91c6e8ca7a495d386773ba2904b6b9b01ecac955ffa10ffbce48338adf589ef3c0f78e9a4ffb0009e886333c7fd8dbe858eb0f33baa52ad24
@@ -12,7 +12,7 @@ Hash.class_eval do
12
12
  if block_given?
13
13
  yield(key, this_val, other_val)
14
14
  else
15
- other_val.presence || this_val
15
+ RubyRailsExtensions.presence(other_val) || this_val
16
16
  end
17
17
  end
18
18
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyRailsExtensions
4
- VERSION = '2.1.0-rc.8'
4
+ VERSION = '2.1.0-rc.9'
5
5
  end
@@ -111,13 +111,15 @@ module RubyRailsExtensions
111
111
  end
112
112
  end
113
113
 
114
+ module_function
115
+
114
116
  # @return [Configuration]
115
- def self.configuration
117
+ def configuration
116
118
  @configuration ||= Configuration.new
117
119
  end
118
120
 
119
121
  # @yield [Configuration]
120
- def self.configure
122
+ def configure
121
123
  yield(configuration)
122
124
 
123
125
  Configuration::BOOLEAN_GEMS.each do |extension|
@@ -132,5 +134,30 @@ module RubyRailsExtensions
132
134
  configuration.flags
133
135
  end
134
136
 
135
- module_function :configuration_flags
137
+ # @see Object#presence from active_support/core_ext/object/blank.rb
138
+ def presence(*items)
139
+ items.each do |item|
140
+ return item if present?(item)
141
+ end
142
+
143
+ nil
144
+ end
145
+
146
+ # @see Object#blank? from active_support/core_ext/object/blank.rb
147
+ def blank?(item)
148
+ if item.respond_to?(:blank?)
149
+ return item.blank?
150
+ end
151
+
152
+ item.respond_to?(:empty?) ? !!item.empty? : !item
153
+ end
154
+
155
+ # @see Object#present? from active_support/core_ext/object/blank.rb
156
+ def present?(item)
157
+ if item.respond_to?(:present?)
158
+ return item.present?
159
+ end
160
+
161
+ !blank?(item)
162
+ end
136
163
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-rails-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0.pre.rc.8
4
+ version: 2.1.0.pre.rc.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brands Insurance