power_converter 0.0.5 → 0.1.0

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
  SHA1:
3
- metadata.gz: d0c79c8bb2c5a433c5e9be7f0d89b38d4f45dddb
4
- data.tar.gz: 98a0b0f03b6f2418321c8cc8f8729792c65c9c5e
3
+ metadata.gz: ee2c06493a4caf6e24704ac9d324b6ea576d2e7e
4
+ data.tar.gz: 5f4debece4a5af37189f0598b7e6d5b3d49220ca
5
5
  SHA512:
6
- metadata.gz: 5be777d8d8d8f932306e80756e0e3b3d6dcbe1345c7b67028e23d4613be8ee00970af60cc0e751282520a7c58ba70802df6ae8825cfef5a0f12596fbaf1de65d
7
- data.tar.gz: 0d611dbdab872ebefb5fa49ec3501132464a8c67a61e392fb119cbad6214270edcf48e76d2428fd8eccbacf2141c2fa990a5ef8f63a4645abe60b490c0a99eb8
6
+ metadata.gz: 1a2e255d8965a7a424d6b10d2f3c6e2a26347560fab683c5e07deda51e51fb47ab9eccc4e44bb5f11181d07474cd499bd68f9a30335ad7d5e43c0c0e42fd5bfa
7
+ data.tar.gz: e75fc34a55012c36cf7d1d8972aaedd5491c44541057a7fcc7baeb700ec979156868033723e198efd31eeb609d02a39d02992539711ca92f1ae011c554af9955
@@ -130,6 +130,8 @@ module PowerConverter
130
130
  # @option options [Symbol] :to the named_conversion that has been registered
131
131
  #
132
132
  # @return [Object] the resulting converted object
133
+ # @yield Yield control to caller if the value could not be converted; This is a good fallback mechanism.
134
+ #
133
135
  #
134
136
  # @raise [ConverterNotFoundError] if the named converter is not found
135
137
  # @raise [ConversionError] if the named converter returned a nil value
@@ -155,6 +157,7 @@ module PowerConverter
155
157
  return value.public_send("to_#{named_converter}") if value.respond_to?("to_#{named_converter}", false)
156
158
  returning_value = converter_for(named_converter).call(value, *scope)
157
159
  return returning_value unless returning_value.nil?
160
+ return yield if block_given?
158
161
  fail ConversionError.new(value, options)
159
162
  end
160
163
 
@@ -234,7 +237,7 @@ module PowerConverter
234
237
 
235
238
  # Useful for when you want to know if a method name is a valid conversion
236
239
  # method name.
237
- CONVERSION_METHOD_REGEXP = /\A#{CONVERSION_METHOD_PREFIX}(.+)\Z/.freeze
240
+ CONVERSION_METHOD_REGEXP = /\A#{CONVERSION_METHOD_PREFIX}(.+)\Z/
238
241
 
239
242
  # @api private
240
243
  # @since 0.0.2
@@ -254,7 +257,7 @@ module PowerConverter
254
257
  def method_missing(method_name, *args, &block)
255
258
  named_converter = extract_named_converter_from(method_name)
256
259
  if named_converter
257
- convert(*args, to: named_converter)
260
+ convert(*args, to: named_converter, &block)
258
261
  else
259
262
  super
260
263
  end
@@ -1,5 +1,5 @@
1
1
  # :nodoc:
2
2
  module PowerConverter
3
3
  # :nodoc:
4
- VERSION = "0.0.5"
4
+ VERSION = "0.1.0".freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: power_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Friesen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-08 00:00:00.000000000 Z
11
+ date: 2016-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler