Module: Trailblazer::Operation::Policy
- Defined in:
- lib/trailblazer/operation/guard.rb,
lib/trailblazer/operation/policy.rb,
lib/trailblazer/operation/pundit.rb
Defined Under Namespace
Modules: Guard, Pundit Classes: Eval
Class Method Summary collapse
- .Guard(proc, name: :default, &block) ⇒ Object
- .Pundit(policy_class, action, name: :default) ⇒ Object
-
.step(condition, options, &block) ⇒ Object
Adds the ‘yield` result to the pipe and treats it like a policy-compatible object at runtime.
Class Method Details
.Guard(proc, name: :default, &block) ⇒ Object
5 6 7 |
# File 'lib/trailblazer/operation/guard.rb', line 5 def self.Guard(proc, name: :default, &block) Policy.step(Guard.build(proc), name: name) end |
.Pundit(policy_class, action, name: :default) ⇒ Object
3 4 5 |
# File 'lib/trailblazer/operation/pundit.rb', line 3 def self.Pundit(policy_class, action, name: :default) Policy.step(Pundit.build(policy_class, action), name: name) end |
.step(condition, options, &block) ⇒ Object
Adds the ‘yield` result to the pipe and treats it like a policy-compatible object at runtime.
25 26 27 28 29 30 31 32 33 |
# File 'lib/trailblazer/operation/policy.rb', line 25 def self.step(condition, , &block) name = [:name] path = "policy.#{name}.eval" step = Eval.new( name: name, path: path ) step = Pipetree::Step.new(step, path => condition) [ step, name: path ] end |