You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* beginning refactor
* more v2 rewrite, removing need for inheritance
* v2 tweaks to rewrite logic
* refactors base run() method, and early prop setting
* rips out old shitty tests, stubs out new ones for logic built so far:
* v2 clean up. Moves core logic changes to lib/. Refactors and fixes base rspec implementation and tests
* refactors spec tests in output spec
* resolves#14 updates readme for V2
* readme updated, again
* v2, refactors all helper classes in spec to mutant_spec_helpers.rb'
* adds tests and logic for running all the mutations's instance validation functions?
* tweaks spec fixtures
* defines required_attr method for mutation classes to define which properties the mutaiton should enforce are present.
* Adds specs for handling required field setting, in both raise_or_error is true and false
* resolves#27 by updating gemsepc
* removes old v1 errors that are not needed
* adds YARD documentation to output.rb
* Adds more YARD documentation
* Delete .byebug_history
* removes byebug from depdencies
Copy file name to clipboardExpand all lines: README.md
+46-26
Original file line number
Diff line number
Diff line change
@@ -15,46 +15,66 @@ gem 'ruby-mutant'
15
15
16
16
Ruby Mutant is a lightweight mutations library to help you encapsulate your business logic. With Ruby Mutant you can easily add executable code with validation, helping you decouple important logic from your application.
17
17
18
-
To create a mutation, subclass `MutatantBase`
18
+
To create a mutation from a ruby object, include the module `include Mutatant`
19
+
19
20
20
21
```ruby
21
22
require"mutant"
22
23
23
-
classProductCreatedMutation < MutantBase
24
-
25
-
#Define required attributes for this mutation to execute
26
-
required do
27
-
{
28
-
name:String,
29
-
address:String,
30
-
product:Product,
31
-
name:String
32
-
}
33
-
end
34
-
35
-
validate do
36
-
[:validate_name?]
37
-
end
24
+
classRecipeCreatedMutation
25
+
includeMutant
38
26
39
27
#Define custom validators for our attributes
40
28
defvalidate_name?
41
29
true
42
30
end
43
31
44
-
# Requried, this will execute our new mutation.
45
-
defself.run(*args)
46
-
super
47
-
input = args[0].to_h
48
-
49
-
# Put all our mutation logic here!
50
-
input[:product].on_sale =true
51
-
52
-
# Output is generated by the Mutator, contains our errors and success? of validation.
53
-
@output
32
+
# Required, this will execute our new mutation.
33
+
defexecute(args)
34
+
# here, recipe is passe into out Class.run(recipe=Recipe.new) method
0 commit comments