Sha256: 25d1c26f9387960f382263f59c8a22594311bf6551f6665be5540ac5fe1623a8
Contents?: true
Size: 1005 Bytes
Versions: 3
Compression:
Stored size: 1005 Bytes
Contents
module PolicyManager::Concerns::UserTerms extend ActiveSupport::Concern def accept_term(term) if current_user user_term = current_user.handle_policy_for(term) return if user_term.accepted? if user_term.accept! term.rule.on_accept.call(self) if term.rule.on_accept.is_a?(Proc) end end cookies["policy_rule_#{term.rule.name}"] = { :value => "accepted", :expires => 1.year.from_now } user_term end def reject_term(term) if current_user user_term = current_user.handle_policy_for(term) return if user_term.rejected? if user_term.reject! term.rule.on_reject.call(self) if term.rule.on_reject.is_a?(Proc) end end cookies.delete("policy_rule_#{term.rule.name}") user_term end # Use callbacks to share common setup or constraints between actions. def policy_term_on(name) category = PolicyManager::Config.rules.find{|o| o.name == name} category.terms.last end end
Version data entries
3 entries across 3 versions & 1 rubygems