Skip to content

Commit ad68001

Browse files
Merge pull request #96 from MichaelSp/patch-1
Update hyper-policy.md
2 parents ce3b3a5 + e63b4f0 commit ad68001

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

docs/dsl-isomorphic/hyper-policy.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ from Mitch...
509509
These work very similar to pundit, and by design you can even mix pundit and hyperloop policies.
510510
Here is an example pundit policy from the pundit tutorial:
511511

512+
```ruby
512513
# app/policies/article_policy.rb
513514
class ArticlePolicy < ApplicationPolicy
514515
def index?
@@ -533,9 +534,9 @@ class ArticlePolicy < ApplicationPolicy
533534
record
534535
end
535536
end
536-
537+
```
537538
--------------
538-
539+
```ruby
539540
class ArticlePolicy < ApplicationPolicy
540541
# def index?
541542
# true
@@ -583,16 +584,19 @@ class ArticlePolicy < ApplicationPolicy
583584
# record
584585
# end
585586
end
587+
```
586588

587589
without comments....
588590

591+
```
589592
class ArticlePolicy < ApplicationPolicy
590593
regulate_broadcast { |policy| policy.send_all.to Application }
591594
592595
allow_create { acting_user } # <- create is okay if acting_user is not nil
593596
594597
allow_change(on: [:update, :destroy]) { acting_user == user }
595598
end
599+
```
596600

597601
BTW what if you want to restrict what data is broadcast? In Hyperloop you just update the regulation. In pundit you may have to edit both the index controller method and
598602
Policy class.

0 commit comments

Comments
 (0)