Sha256: 182b12ca25db274aad023027a1e08a5bc277cd11b461bacccf8a6a43161b490a
Contents?: true
Size: 651 Bytes
Versions: 59
Compression:
Stored size: 651 Bytes
Contents
module Spree module Core module TokenResource module ClassMethods def token_resource has_one :tokenized_permission, :as => :permissable delegate :token, :to => :tokenized_permission, :allow_nil => true after_create :create_token end end def create_token permission = build_tokenized_permission permission.token = token = ::SecureRandom::hex(8) permission.save! token end def self.included(receiver) receiver.extend ClassMethods end end end end ActiveRecord::Base.class_eval { include Spree::Core::TokenResource }
Version data entries
59 entries across 59 versions & 2 rubygems