lib/the_help/service.rb
# Defines the service authorization policy
#
# If allow_all is set to true, or if the provided block (executed in the
# context of the service object) returns true, then the service will be
# run when called. Otherwise, the not_authorized callback will be invoked.
#
# @param allow_all [Boolean]
# @param block [Proc] executed in the context of the service instance (and
#   can therefore access all inputs to the service)
Defines the service authorization policy
If allow_all is set to true, or if the provided block (executed in the
context of the service object) returns true, then the service will be
run when called. Otherwise, the not_authorized callback will be invoked.
Defines the service authorization policy If allow_all is set to true or if the provided block ( executed in the context of the service object ) returns true then the service will be run when called . Otherwise the not_authorized callback will be invoked .
def authorization_policy(allow_all: false, &block)
        if allow_all
          define_method(:authorized?) { true }
        else
          define_method(:authorized?, &block)
        end
        private :authorized?
        self
      end
def authorization_policy ( allow_all : false , & block ) if allow_all define_method ( :authorized? ) { true } else define_method ( :authorized? , & block ) end private :authorized? self end
Defines the service authorization policy
If allow_all is set to true, or if the provided block (executed in the
context of the service object) returns true, then the service will be
run when called.
Defines the service authorization policy If allow_all is set to true or if the provided block ( executed in the context of the service object ) returns true then the service will be run when called .
allow_all
<not_specific>
block
executed in the context of the service instance (and can therefore access all inputs to the service)
executed in the context of the service instance ( and can therefore access all inputs to the service )
<not_specific>
None