Skip to content

Commit

Permalink
Put a space between code fence blocks and the syntax name
Browse files Browse the repository at this point in the history
  • Loading branch information
tfausak committed Dec 10, 2014
1 parent 4ac7497 commit 4d0ebe3
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ it will call `execute`, store the return value of that method in
`result`, and return an instance of your ActiveInteraction::Base
subclass. Let's look at a simple example:

```ruby
``` ruby
# Define an interaction that signs up a user.
class UserSignup < ActiveInteraction::Base
# required
Expand Down Expand Up @@ -103,7 +103,7 @@ ActiveRecord is available.
There are two way to call an interaction. Given UserSignup, you can
do this:

```ruby
``` ruby
outcome = UserSignup.run(params)
if outcome.valid?
# Do something with outcome.result...
Expand All @@ -114,7 +114,7 @@ end

Or, you can do this:

```ruby
``` ruby
result = UserSignup.run!(params)
# Either returns the result of execute,
# or raises ActiveInteraction::InvalidInteractionError
Expand All @@ -124,7 +124,7 @@ result = UserSignup.run!(params)

Interactions only accept a Hash for `run` and `run!`.

```ruby
``` ruby
# A user comments on an article
class CreateComment < ActiveInteraction::Base
model :article, :user
Expand All @@ -148,15 +148,15 @@ end

1. Subclass ActiveInteraction::Base

```ruby
``` ruby
class YourInteraction < ActiveInteraction::Base
# ...
end
```

2. Define your attributes:

```ruby
``` ruby
string :name, :state
integer :age
boolean :is_special
Expand All @@ -174,7 +174,7 @@ end

3. Use any additional validations you need:

```ruby
``` ruby
validates :name, length: { maximum: 10 }
validates :state, inclusion: { in: %w(AL AK AR ... WY) }
validate :arrives_before_departs
Expand All @@ -190,7 +190,7 @@ end

4. Define your execute method. It can return whatever you like:

```ruby
``` ruby
def execute
record = do_thing(...)
# ...
Expand All @@ -207,7 +207,7 @@ If the interaction is successful, it'll return the result (just like if you had
called it with `run!`). If something went wrong, execution will halt
immediately and the errors will be moved onto the caller.

```ruby
``` ruby
class AddThree < ActiveInteraction::Base
integer :x
def execute
Expand All @@ -221,7 +221,7 @@ AddThree.run!(x: 5)
To bring in filters from another interaction, use `import_filters`. Combined
with `inputs`, delegating to another interaction is a piece of cake.

```ruby
``` ruby
class AddAndDouble < ActiveInteraction::Base
import_filters Add
def execute
Expand All @@ -238,7 +238,7 @@ into `config/locales`. So, for example, let's say that (for whatever
reason) you want to print out everything backwards. Simply add
translations for ActiveInteraction to your `hsilgne` locale:

```yaml
``` yaml
# config/locales/hsilgne.yml
hsilgne:
active_interaction:
Expand All @@ -264,7 +264,7 @@ hsilgne:

Then set your locale and run an interaction like normal:

```ruby
``` ruby
I18n.locale = :hsilgne
class Interaction < ActiveInteraction::Base
boolean :a
Expand Down

0 comments on commit 4d0ebe3

Please sign in to comment.