reform-rails 0.1.2 → 0.1.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: 9fbb0b2b6aa7d3e8ae82a3f6939d57c667539045
4
- data.tar.gz: 713f08258c3d5153c84421478618e495e9786524
3
+ metadata.gz: 1400de06d17da697f8c4a7e86191ed5a39b4c6dc
4
+ data.tar.gz: f64c23b9d6e57f89dcb5ab0fd5bba9cbe96163d3
5
5
  SHA512:
6
- metadata.gz: 50d716e314c1d7357265999b7261c8d1b8d8615938513eb1059f902f340c8d130f83012f0d03c943359173899923836bbe11d6762563f29e8a022d8ae44420ca
7
- data.tar.gz: d24374d8cf04c4460db532353d85f2d2b999b9e31390be8e05296c5989cd9c9303cbe7d314eb3e49942425bed01bfd2598acd539e45406abd858cbfc33822f53
6
+ metadata.gz: 8f6a025bb35d41901c746733b40f1979f579c60ac21d38cb49212a545b7a17905b2c4880bfd3b8a12fc2f2682950b032359193b932d4ce6ad81d1e70dfbcf3c4
7
+ data.tar.gz: 7429e04e455a6237f78019a41d04775ca4b2481c8ad5a9402979646c2b9472f1bd8d9a41e49fea3d63198316ce2bd026bc066a6c22ab2fdbea92bbe1b6a99419
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.1.3
2
+
3
+ * Introduce a railtie to load either `ActiveModel::Validations` *or* `Dry::Validations`. This can be controller via `config.reform.validations = :dry`.
4
+
1
5
  # 0.1.2
2
6
 
3
7
  * Allow Reform-2.2.0.rc1 in gemspec.
data/database.sqlite3 CHANGED
Binary file
@@ -1,5 +1,3 @@
1
- require "reform/form/active_model/model_validations"
2
- require "reform/form/active_model/form_builder_methods"
3
1
  require "uber/delegates"
4
2
 
5
3
  module Reform::Form::ActiveModel
@@ -0,0 +1,57 @@
1
+ module Reform
2
+ module Rails
3
+ class Railtie < ::Rails::Railtie
4
+ config.reform = ActiveSupport::OrderedOptions.new
5
+
6
+ initializer "reform.form_extensions", before: :load_config_initializers do
7
+ validations = config.reform.validations || :active_model
8
+
9
+ if validations == :active_model
10
+ active_model!
11
+ elsif validations == :dry
12
+ dry!
13
+ else
14
+ warn "[Reform::Rails] No validation backend set. Please do so via `config.reform.validations = :active_model`."
15
+ end
16
+ end
17
+
18
+ def active_model!
19
+ require "reform"
20
+ require "reform/form/active_model/model_validations"
21
+ require "reform/form/active_model/form_builder_methods"
22
+ require "reform/form/active_model"
23
+ require "reform/form/active_model/validations"
24
+ require "reform/form/multi_parameter_attributes"
25
+
26
+ require "reform/active_record" if defined?(ActiveRecord)
27
+ require "reform/mongoid" if defined?(Mongoid)
28
+
29
+ Reform::Form.class_eval do
30
+ include Reform::Form::ActiveModel
31
+ include Reform::Form::ActiveModel::FormBuilderMethods
32
+ include Reform::Form::ActiveRecord if defined?(ActiveRecord)
33
+ include Reform::Form::Mongoid if defined?(Mongoid)
34
+ include Reform::Form::ActiveModel::Validations
35
+ end
36
+ end
37
+
38
+ def dry!
39
+ require "reform"
40
+ require "reform/form/dry"
41
+
42
+ require "reform/form/multi_parameter_attributes"
43
+ require "reform/form/active_model/form_builder_methods" # this is for simple_form, etc.
44
+
45
+ # This adds Form#persisted? and all the other crap #form_for depends on. Grrrr.
46
+ require "reform/form/active_model" # DISCUSS: only when using simple_form.
47
+
48
+ Reform::Form.class_eval do
49
+ include Reform::Form::ActiveModel # DISCUSS: only when using simple_form.
50
+ include Reform::Form::ActiveModel::FormBuilderMethods
51
+
52
+ include Reform::Form::Dry
53
+ end
54
+ end
55
+ end # Railtie
56
+ end
57
+ end
@@ -1,5 +1,5 @@
1
1
  module Reform
2
2
  module Rails
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
data/lib/reform/rails.rb CHANGED
@@ -1,21 +1,5 @@
1
1
  require "reform/rails/version"
2
-
3
- require "reform"
4
- require "reform/form/active_model"
5
- require "reform/form/active_model/validations"
6
- require "reform/form/multi_parameter_attributes"
7
-
8
-
9
- require "reform/active_record" if defined?(ActiveRecord)
10
- require "reform/mongoid" if defined?(Mongoid)
11
-
12
- Reform::Form.class_eval do
13
- include Reform::Form::ActiveModel
14
- include Reform::Form::ActiveModel::FormBuilderMethods
15
- include Reform::Form::ActiveRecord if defined?(ActiveRecord)
16
- include Reform::Form::Mongoid if defined?(Mongoid)
17
- include Reform::Form::ActiveModel::Validations
18
- end
2
+ require "reform/rails/railtie"
19
3
 
20
4
  module Reform
21
5
  def self.rails3_0?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reform-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-18 00:00:00.000000000 Z
11
+ date: 2016-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reform
@@ -181,6 +181,7 @@ files:
181
181
  - lib/reform/form/multi_parameter_attributes.rb
182
182
  - lib/reform/form/validation/unique_validator.rb
183
183
  - lib/reform/rails.rb
184
+ - lib/reform/rails/railtie.rb
184
185
  - lib/reform/rails/version.rb
185
186
  - reform-rails.gemspec
186
187
  homepage: https://github.com/trailblazer/reform-rails