rails_string_enum 0.5.2 → 0.5.3

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: fd1412a1c0dac183ae69c88086a0ffeb6bbda037
4
- data.tar.gz: 4752e6e49b181d8834bae7ccad994c40b0549992
3
+ metadata.gz: 5ffee91f4b0ce3428ba935ae14a4ef9ff25fd29f
4
+ data.tar.gz: 9c690218888e9461d46a6509d0982af6fdb70a7f
5
5
  SHA512:
6
- metadata.gz: 2c798f679a946b0ce24af2059da2dd47dd56dee2cc52be356d4d06eea8af964df1edd6148dc592bcde189c12ffe88911e624a8791ca3d30a2f338317cfd8ae19
7
- data.tar.gz: e2f2aed68d85a2d95d293d32915801e51378cc97cfbd93b9fe5300f6deabae5542bab68721d71ee6cd18ed5f96956676d3c5e92e72b6e26d4df5167af29bf7f8
6
+ metadata.gz: e41e44d7a4d245b06c46f2b7723099105c6f1e9f2ac6ccfef39ef785a10fa6a845d8b1fe0fe9f40dbb045db409f40af5dcdf9773c86c775d86c8b39a65568390
7
+ data.tar.gz: 4222fd47916c08802755aab4ce9659ff1bf8bf8159b41c3361fc2556d56b0f0869fb0d9605d5a860609590d05be53054977a0cb7d59c9c4484059e262ce5d4bf
data/README.md CHANGED
@@ -46,7 +46,7 @@ delete_enum_value :color, 'black'
46
46
  ###### Convert exist columns (int, string) to postgresql enum
47
47
  ```ruby
48
48
  string_to_enums :product, :color, enum_name: 'product_color_enum', definitions: %w(red green blue), default: 'green'
49
- string_to_enums :product, :color, enum_name: 'product_color_enum', definitions: Product.uniq.pluck(:color)
49
+ string_to_enums :product, :color, enum_name: 'product_color_enum', definitions: Product.unscoped.uniq.pluck(:color).compact
50
50
 
51
51
  int_to_enums :product, :color, enum_name: 'product_color_enum', definitions: { red: 0, green: 1, blue: 2 }
52
52
  ```
@@ -1,22 +1,21 @@
1
1
  require 'simple_form'
2
2
 
3
- module EnumHelp
4
- module SimpleForm
5
- module BuilderExtension
6
-
7
- def default_input_type_with_enum(*args, &block)
8
- attr_name = (args.first || @attribute_name).to_s
9
- options = args.last
3
+ module BuilderExtensionWithEnum
4
+ def default_input_type(*args, &block)
5
+ attr_name = (args.first || @attribute_name).to_s
6
+ options = args.last
10
7
 
11
- const_for_attr = object.respond_to? "#{attr_name}_i18n"
8
+ const_for_attr = object.respond_to? "#{attr_name}_i18n"
12
9
 
13
- return :enum_radio_buttons if options.is_a?(Hash) && options[:as] == :radio_buttons && const_for_attr
14
- return :enum if (options.is_a?(Hash) ? options[:as] : @options[:as]).nil? && const_for_attr
10
+ return :enum_radio_buttons if options.is_a?(Hash) && options[:as] == :radio_buttons && const_for_attr
11
+ return :enum if (options.is_a?(Hash) ? options[:as] : @options[:as]).nil? && const_for_attr
15
12
 
16
- default_input_type_without_enum(*args, &block)
17
- end
18
- end
13
+ super(*args, &block)
14
+ end
15
+ end
19
16
 
17
+ module EnumHelp
18
+ module SimpleForm
20
19
  module InputExtension
21
20
 
22
21
  def initialize(*args)
@@ -59,11 +58,9 @@ end
59
58
 
60
59
 
61
60
  SimpleForm::FormBuilder.class_eval do
62
- include EnumHelp::SimpleForm::BuilderExtension
63
-
64
61
  map_type :enum, :to => EnumHelp::SimpleForm::EnumInput
65
62
  map_type :enum_radio_buttons, :to => EnumHelp::SimpleForm::EnumRadioButtons
66
63
  alias_method :collection_enum_radio_buttons, :collection_radio_buttons
67
64
  alias_method :collection_enum, :collection_select
68
- alias_method_chain :default_input_type, :enum
69
- end
65
+ prepend BuilderExtensionWithEnum
66
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsStringEnum
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_string_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ermolaev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-09 00:00:00.000000000 Z
11
+ date: 2017-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  version: '0'
65
65
  requirements: []
66
66
  rubyforge_project:
67
- rubygems_version: 2.4.8
67
+ rubygems_version: 2.6.11
68
68
  signing_key:
69
69
  specification_version: 4
70
70
  summary: support in rails db enums or string (using as flexible enum)