event_hooks 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +24 -2
  2. data/lib/event_hooks/version.rb +1 -1
  3. metadata +1 -1
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # EventHooks
2
2
 
3
- TODO: Write a gem description
3
+ EventHooks enhances Ruby classes to allow adding pre-conditions to method calls (events).
4
+ If the pre-conditions method returns false the event method will not run. It can be used on ActiveRecord subclasses to validate some conditions only when a certain event occurs.
4
5
 
5
6
  ## Installation
6
7
 
@@ -18,7 +19,28 @@ Or install it yourself as:
18
19
 
19
20
  ## Usage
20
21
 
21
- TODO: Write usage instructions here
22
+ Within the class that you want to hook the pre-condition to simply write:
23
+ ```ruby
24
+ hook_before :event, :hook
25
+ ```
26
+
27
+ where:
28
+ * event is the name of a method that you must define prior to the hook_before.
29
+ * hook is the name of a method that will be run before the call to event.
30
+
31
+ ```ruby
32
+ class AnyClass
33
+ def submit
34
+ # do something
35
+ end
36
+ hook_before :submit, :submit_preconditions
37
+
38
+ def submit_preconditions
39
+ am_i_ready?
40
+ end
41
+ end
42
+ ```
43
+
22
44
 
23
45
  ## Contributing
24
46
 
@@ -1,3 +1,3 @@
1
1
  module EventHooks
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_hooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: