power_enum 2.10.1 → 2.11.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: 6ac12a5b4f50ccee6d7839723743127f7685a4d1
4
- data.tar.gz: 07be49484211a0df77854933918aa8bdc71911db
3
+ metadata.gz: 893addf87676cb3a7a981c4183799d2b67b7c60f
4
+ data.tar.gz: a46af4984122a09568cdd6f11ba65114c2a6cde7
5
5
  SHA512:
6
- metadata.gz: c0b03b94700687d18ec270597da7a96163ab751a90586924e368d1081117b581854cb2c19aad11e317325e695ccda1b124b312e6b143cb501eb67b29fe933a41
7
- data.tar.gz: e4e96caf1cefea850e9097a7e4ff0cce9af6eeab9e81d3ec1b4ec0b94a6f597e611da3a0cb4ebf73d8d9d130f34b25ddf6538b12cf44ee15c2d4d97a70ced7ba
6
+ metadata.gz: 71d9e4aae317d96629faac94ba16714a1f6ab8b6a3533a4bd19e019d4b38d85ff051965efd58dbf779e2f965e187c3801683ef07c9898811bdb939a2193ec435
7
+ data.tar.gz: afbd9d683a316c7d34fbc41480a15960db66048dc55b7b98960e6ce0f7164299ee50a0f0ee90eb307c97f44ca663f34275a0c69bc98ed3627cdd7204a6f32687
data/README.markdown CHANGED
@@ -307,13 +307,13 @@ With that, your BookingStatus class will have the following methods defined:
307
307
 
308
308
  `BookingStatus[arg]` performs a lookup for the BookingStatus instance for the given arg. The arg value can be a
309
309
  'string' or a :symbol, in which case the lookup will be against the BookingStatus.name field. Alternatively arg can be
310
- a Fixnum, in which case the lookup will be against the BookingStatus.id field. It returns the arg if arg is an
310
+ a Integer, in which case the lookup will be against the BookingStatus.id field. It returns the arg if arg is an
311
311
  instance of the enum (in this case BookingStatus) as a convenience.
312
312
 
313
313
  The `:on_lookup_failure` option specifies the name of a *class* method to invoke when the `[]` method is unable to
314
314
  locate a BookingStatus record for arg. The default is the built-in `:enforce_none` which returns nil. There are also
315
315
  built-ins for `:enforce_strict` (raise and exception regardless of the type for arg), `:enforce_strict_literals` (raises
316
- an exception if the arg is a Fixnum or Symbol), `:enforce_strict_ids` (raises and exception if the arg is a Fixnum) and
316
+ an exception if the arg is a Integer or Symbol), `:enforce_strict_ids` (raises and exception if the arg is a Integer) and
317
317
  `:enforce_strict_symbols` (raises an exception if the arg is a Symbol).
318
318
 
319
319
  The purpose of the `:on_lookup_failure` option is that a) under some circumstances a lookup failure is a Bad Thing and
@@ -388,7 +388,7 @@ Each enumeration model gets the following instance methods.
388
388
  Behavior depends on the type of `arg`.
389
389
 
390
390
  * If `arg` is `nil`, returns `false`.
391
- * If `arg` is an instance of `Symbol`, `Fixnum` or `String`, returns the result of `BookingStatus[:foo] == BookingStatus[arg]`.
391
+ * If `arg` is an instance of `Symbol`, `Integer` or `String`, returns the result of `BookingStatus[:foo] == BookingStatus[arg]`.
392
392
  * If `arg` is an `Array`, returns `true` if any member of the array returns `true` for `===(arg)`, `false` otherwise.
393
393
  * In all other cases, delegates to `===(arg)` of the superclass.
394
394
 
@@ -4,7 +4,7 @@ module EnumGeneratorHelpers
4
4
  module MigrationNumber
5
5
  # Returns the next upcoming migration number. Sadly, Rails has no API for
6
6
  # this, so we're reduced to copying from ActiveRecord::Generators::Migration
7
- # @return [Fixnum]
7
+ # @return [Integer]
8
8
  def next_migration_number(dirname)
9
9
  # Lifted directly from ActiveRecord::Generators::Migration
10
10
  # Unfortunately, no API is provided by Rails at this time.
@@ -25,8 +25,8 @@ module PowerEnum::Enumerated
25
25
  # Specifies the name of a class method to invoke when the +[]+ method is unable to locate a BookingStatus
26
26
  # record for arg. The default is the built-in :enforce_none which returns nil. There are also built-ins for
27
27
  # :enforce_strict (raise and exception regardless of the type for arg), :enforce_strict_literals (raises an
28
- # exception if the arg is a Fixnum or Symbol), :enforce_strict_ids (raises and exception if the arg is a
29
- # Fixnum) and :enforce_strict_symbols (raises an exception if the arg is a Symbol). The purpose of the
28
+ # exception if the arg is a Integer or Symbol), :enforce_strict_ids (raises and exception if the arg is a
29
+ # Integer) and :enforce_strict_symbols (raises an exception if the arg is a Symbol). The purpose of the
30
30
  # :on_lookup_failure option is that a) under some circumstances a lookup failure is a Bad Thing and action
31
31
  # should be taken, therefore b) a fallback action should be easily configurable. You can also give it a
32
32
  # lambda that takes in a single argument (The arg that was passed to +[]+).
@@ -218,7 +218,7 @@ module PowerEnum::Enumerated
218
218
  !!lookup_name(arg.id2name)
219
219
  when String
220
220
  !!lookup_name(arg)
221
- when Fixnum
221
+ when Integer
222
222
  !!lookup_id(arg)
223
223
  when self
224
224
  true
@@ -244,7 +244,7 @@ module PowerEnum::Enumerated
244
244
  !lookup_name(arg.id2name).nil?
245
245
  when String
246
246
  !lookup_name(arg).nil?
247
- when Fixnum
247
+ when Integer
248
248
  !lookup_id(arg).nil?
249
249
  when self
250
250
  possible_match = lookup_id(arg.id)
@@ -322,7 +322,7 @@ module PowerEnum::Enumerated
322
322
  lookup_name(arg.id2name)
323
323
  when String
324
324
  lookup_name(arg)
325
- when Fixnum
325
+ when Integer
326
326
  lookup_id(arg)
327
327
  when self
328
328
  arg
@@ -330,7 +330,7 @@ module PowerEnum::Enumerated
330
330
  nil
331
331
  else
332
332
  raise TypeError, "#{self.name}[]: argument should"\
333
- " be a String, Symbol or Fixnum but got a: #{arg.class.name}"
333
+ " be a String, Symbol or Integer but got a: #{arg.class.name}"
334
334
  end
335
335
  end
336
336
  private :lookup_enum_by_type
@@ -390,13 +390,13 @@ module PowerEnum::Enumerated
390
390
  private :enforce_strict
391
391
 
392
392
  def enforce_strict_literals(arg) # :nodoc:
393
- raise_record_not_found(arg) if (Fixnum === arg) || (Symbol === arg)
393
+ raise_record_not_found(arg) if (Integer === arg) || (Symbol === arg)
394
394
  nil
395
395
  end
396
396
  private :enforce_strict_literals
397
397
 
398
398
  def enforce_strict_ids(arg) # :nodoc:
399
- raise_record_not_found(arg) if Fixnum === arg
399
+ raise_record_not_found(arg) if Integer === arg
400
400
  nil
401
401
  end
402
402
  private :enforce_strict_ids
@@ -421,7 +421,7 @@ module PowerEnum::Enumerated
421
421
  # Behavior depends on the type of +arg+.
422
422
  #
423
423
  # * If +arg+ is +nil+, returns +false+.
424
- # * If +arg+ is an instance of +Symbol+, +Fixnum+ or +String+, returns the result of +BookingStatus[:foo] == BookingStatus[arg]+.
424
+ # * If +arg+ is an instance of +Symbol+, +Integer+ or +String+, returns the result of +BookingStatus[:foo] == BookingStatus[arg]+.
425
425
  # * If +arg+ is an +Array+, returns +true+ if any member of the array returns +true+ for +===(arg)+, +false+ otherwise.
426
426
  # * In all other cases, delegates to +===(arg)+ of the superclass.
427
427
  #
@@ -439,7 +439,7 @@ module PowerEnum::Enumerated
439
439
  case arg
440
440
  when nil
441
441
  false
442
- when Symbol, String, Fixnum
442
+ when Symbol, String, Integer
443
443
  return self == self.class[arg]
444
444
  when Array
445
445
  return self.in?(*arg)
@@ -172,14 +172,14 @@ module PowerEnum::HasEnumerated
172
172
  val = #{class_name}.lookup_name(arg)
173
173
  when Symbol
174
174
  val = #{class_name}.lookup_name(arg.id2name)
175
- when Fixnum
175
+ when Integer
176
176
  val = #{class_name}.lookup_id(arg)
177
177
  when nil
178
178
  self.#{foreign_key} = nil
179
179
  @invalid_enum_values.delete :#{attribute_name}
180
180
  return nil
181
181
  else
182
- raise TypeError, "#{self.name}: #{attribute_name}= argument must be a #{class_name}, String, Symbol or Fixnum but got a: \#{arg.class.attribute_name}"
182
+ raise TypeError, "#{self.name}: #{attribute_name}= argument must be a #{class_name}, String, Symbol or Integer but got a: \#{arg.class.attribute_name}"
183
183
  end
184
184
 
185
185
  if val.nil?
data/lib/testing/rspec.rb CHANGED
@@ -71,7 +71,7 @@ if defined? RSpec
71
71
  # Validates the given enum.
72
72
  def validate_enum(enum_class, item)
73
73
  case item
74
- when String, Symbol, Fixnum
74
+ when String, Symbol, Integer
75
75
  enum_class[item].present?
76
76
  when Hash
77
77
  name = item[:name]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: power_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.1
4
+ version: 2.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trevor Squires
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-01-04 00:00:00.000000000 Z
14
+ date: 2017-05-25 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  version: '0'
166
166
  requirements: []
167
167
  rubyforge_project:
168
- rubygems_version: 2.4.8
168
+ rubygems_version: 2.6.8
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: Allows you to treat instances of your ActiveRecord models as though they