rectify 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67f7776f5c98dc7017150f2c7c361c62605dce6f
4
- data.tar.gz: 6b8ab74b2a86b8f8ae72ded1ab299659337230e0
3
+ metadata.gz: deb2b71f7c40c0fb4757215a7ba7410ef9a627c4
4
+ data.tar.gz: 45b9aee2aae6176d9acabaa246eb21615c3470e9
5
5
  SHA512:
6
- metadata.gz: e8fb81cc7e16eb530ab307073735de1abb085a509f9278ef3dfe6da85c0f92ac58e1ee32260022c3b68fa3df9e2fe4c0e018adbc94b4d02c07f719c079ce1e77
7
- data.tar.gz: 4b027533b746f6a90241a6029b2fb50b3bda07c6a419dea59191372d7c0fe43eb85d78a1c90be2a51c6f3f8cb64c5c45994a05f507d09b18ff5c14e9611b8859
6
+ metadata.gz: d97d1edb9d00fe805110457ad9613a304983fa018681bd10baf26d362f22b33f186900634d1c62718459fb40dc9a58052ef0dc507f3ecf3c04f8185910c4dfbb
7
+ data.tar.gz: 726f511c00978ed1dd2f475bbd4f783465a3a3b5680816157f70df693204eaa6e48d03541f2438dfe5d1afff4a181356e7b272b6c5f35084597037bbee740c1f
data/lib/rectify/form.rb CHANGED
@@ -70,6 +70,8 @@ module Rectify
70
70
  end
71
71
 
72
72
  def valid?(context = nil)
73
+ before_validation
74
+
73
75
  [super, form_attributes_valid?, arrays_attributes_valid?].all?
74
76
  end
75
77
 
@@ -95,6 +97,11 @@ module Rectify
95
97
  # populated (optional).
96
98
  end
97
99
 
100
+ def before_validation
101
+ # Implement this in your form object if you would like to perform some
102
+ # some processing before validation happens (optional).
103
+ end
104
+
98
105
  private
99
106
 
100
107
  def form_attributes_valid?
@@ -1,3 +1,3 @@
1
1
  module Rectify
2
- VERSION = "0.6.1".freeze
2
+ VERSION = "0.7.0".freeze
3
3
  end
data/readme.md CHANGED
@@ -11,9 +11,18 @@ several other gems and adds improved APIs to make things easier.
11
11
  Rectify is an extraction from a number of projects that use these techniques and
12
12
  proved to be successful.
13
13
 
14
+ ## Video
15
+
16
+ In June 2016, I spoke at RubyC about Rectify and how it can be used to improve
17
+ areas of your application. The full video and slides can be found here:
18
+
19
+ [Building maintainable Rails apps - RubyC 2016](http://andypike.com/blog/conferences/rubyc-2016/)
20
+
21
+ ## Installation
22
+
14
23
  To install, add it to your `Gemfile`:
15
24
 
16
- ```
25
+ ```ruby
17
26
  gem "rectify"
18
27
  ```
19
28
 
@@ -349,7 +358,7 @@ form.age # => 38
349
358
  ```
350
359
 
351
360
  Populating the form from JSON can be useful when dealing with API requests into
352
- your system. Which allows you to easily access data and perform validation if
361
+ your system. Which allows you to easily access data and perform validation if
353
362
  required.
354
363
 
355
364
  ### Validations
@@ -408,7 +417,7 @@ class RegisterAccount < Rectify::Command
408
417
  return broadcast(:invalid) if form.invalid?
409
418
 
410
419
  transaction do
411
- creates_user
420
+ create_user
412
421
  notifiy_admins
413
422
  audit_event
414
423
  send_user_details_to_crm
@@ -421,7 +430,7 @@ class RegisterAccount < Rectify::Command
421
430
 
422
431
  attr_reader :form
423
432
 
424
- def creates_user
433
+ def create_user
425
434
  # ...
426
435
  end
427
436
 
@@ -532,7 +541,7 @@ def create
532
541
  end
533
542
  ```
534
543
 
535
- ```html
544
+ ```erb
536
545
  <!-- within the view: -->
537
546
 
538
547
  <p><%= @greeting %> <%= presenter.name %></p>
@@ -591,7 +600,7 @@ You need to call `#attach_controller` and pass it a controller instance which wi
591
600
  allow it access to the view helpers. You can then use the Presenter in your
592
601
  views as you would expect:
593
602
 
594
- ```html
603
+ ```erb
595
604
  <p><%= @presenter.edit_link %></p>
596
605
  ```
597
606
 
@@ -613,7 +622,7 @@ end
613
622
 
614
623
  In your view, you can access this presenter using the `presenter` helper method:
615
624
 
616
- ```html
625
+ ```erb
617
626
  <p><%= presenter.edit_link %></p>
618
627
  ```
619
628
 
@@ -633,7 +642,7 @@ end
633
642
  To access this Presenter in the view, just pass the Presenter key to the
634
643
  `presenter` method like so:
635
644
 
636
- ```html
645
+ ```erb
637
646
  <p><%= presenter(:layout).login_link %></p>
638
647
  ```
639
648
 
@@ -1065,7 +1074,7 @@ specs with `bundle exec rspec`, the database will be created for you.
1065
1074
  There are some Rake tasks to help with the management of this test database
1066
1075
  using normal(ish) commands from Rails:
1067
1076
 
1068
- ```
1077
+ ```sh
1069
1078
  rake db:migrate # => Migrates the test database
1070
1079
  rake db:schema # => Dumps database schema
1071
1080
  rake g:migration # => Create a new migration file (use snake_case name)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rectify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Pike
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-13 00:00:00.000000000 Z
11
+ date: 2016-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus